CF245F.Log Stream Analysis
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You've got a list of program warning logs. Each record of a log stream is a string in this format:
"2012-MM-DD HH:MM:SS:MESSAGE" (without the quotes).
String "MESSAGE" consists of spaces, uppercase and lowercase English letters and characters "!", ".", ",", "?". String "2012-MM-DD" determines a correct date in the year of 2012. String "HH:MM:SS" determines a correct time in the 24 hour format.
The described record of a log stream means that at a certain time the record has got some program warning (string "MESSAGE" contains the warning's description).
Your task is to print the first moment of time, when the number of warnings for the last n seconds was not less than m.
你有一组程序警告日志。每条日志记录是一个如下格式的字符串:
"2012-MM-DD HH:MM:SS:MESSAGE"(不含引号)。
其中,字符串 MESSAGE 由空格、大小写英文字母以及字符 !、.、,、? 组成;字符串 2012-MM-DD 表示 2012 年内的一个合法日期;字符串 HH:MM:SS 表示 24 小时制下的一个合法时间。
上述日志记录表示:在某一时刻,程序产生了某条警告(字符串 MESSAGE 中包含该警告的描述)。
你的任务是输出满足以下条件的最早时刻:在该时刻之前的最近 n 秒内(含该时刻本身),警告数量不少于 m。
输入格式
The first line of the input contains two space-separated integers n and m (1 ≤ n, m ≤ 10000).
The second and the remaining lines of the input represent the log stream. The second line of the input contains the first record of the log stream, the third line contains the second record and so on. Each record of the log stream has the above described format. All records are given in the chronological order, that is, the warning records are given in the order, in which the warnings appeared in the program.
It is guaranteed that the log has at least one record. It is guaranteed that the total length of all lines of the log stream doesn't exceed 5·106 (in particular, this means that the length of some line does not exceed 5·106 characters). It is guaranteed that all given dates and times are correct, and the string 'MESSAGE" in all records is non-empty.
输入的第一行包含两个以空格分隔的整数 n 和 m(1 ≤ n, m ≤ 10000)。
输入的第二行及后续各行表示日志流。输入的第二行包含日志流中的第一条记录,第三行包含第二条记录,依此类推。每条日志流记录均采用上述描述的格式。所有记录均按时间顺序给出,即警告记录按照其在程序中实际出现的顺序给出。
保证日志至少包含一条记录;保证日志流所有行的总长度不超过 5⋅106(特别地,这意味着某一行的长度也不超过 5⋅106 个字符);保证所有给定的日期和时间均正确,且所有记录中的字符串 MESSAGE 均为非空。
输出格式
If there is no sought moment of time, print -1. Otherwise print a string in the format "2012-MM-DD HH:MM:SS" (without the quotes) — the first moment of time when the number of warnings for the last n seconds got no less than m.
如果不存在所求的时间点,则输出 -1。否则,输出格式为 "2012-MM-DD HH:MM:SS"(不含引号)的字符串——即最近 n 秒内警告次数首次不少于 m 的时间点。
输入输出样例
输入#1
60 3 2012-03-16 16:15:25: Disk size is 2012-03-16 16:15:25: Network failute 2012-03-16 16:16:29: Cant write varlog 2012-03-16 16:16:42: Unable to start process 2012-03-16 16:16:43: Disk size is too small 2012-03-16 16:16:53: Timeout detected
输出#1
2012-03-16 16:16:43
输入#2
1 2 2012-03-16 23:59:59:Disk size 2012-03-17 00:00:00: Network 2012-03-17 00:00:01:Cant write varlog
输出#2
-1
输入#3
2 2 2012-03-16 23:59:59:Disk size is too sm 2012-03-17 00:00:00:Network failute dete 2012-03-17 00:00:01:Cant write varlogmysq
输出#3
2012-03-17 00:00:00
输入解题思路,AI测评打分。不知道怎么写?