您的位置:首页 > 其它

CROC-MBTU 2012, Elimination Round / 245F Log Stream Analysis (日期处理&二分)

2014-03-09 10:55 435 查看
http://codeforces.com/problemset/problem/245/F

/*60ms,16600KB*/

#include<bits/stdc++.h>
using namespace std;
const int mx = 5000005;
const int month[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int day2s = 24 * 3600;
char str[mx];
int t[3000005], mm, mo, d, h, m, s, cnt;

inline int cnt_s()
{
	int ans = 0;
	for (int i = 1; i < mo; ++i) ans += month[i];
	ans += d - 1;
	ans *= day2s;
	ans += h * 3600 + m * 60 + s;
	return ans;
}

inline bool judge(int now)
{
	return t + cnt - lower_bound(t, t + cnt, now) >= mm;
}

int main()
{
	int len;
	scanf("%d%d", &len, &mm);
	getchar();
	bool ok = false;
	while (gets(str))
	{
		sscanf(str, "%*d%*c%d%*c%d %d%*c%d%*c%d", &mo, &d, &h, &m, &s);
		t[cnt++] = cnt_s();
		if (judge(t[cnt - 1] - len + 1))
		{
			printf("2012-%02d-%02d %02d:%02d:%02d\n", mo, d, h, m, s);
			ok = true;
			break;
		}
	}
	if (!ok) puts("-1");
	return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐