-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDONALDO.cpp
More file actions
42 lines (42 loc) · 806 Bytes
/
DONALDO.cpp
File metadata and controls
42 lines (42 loc) · 806 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
scanf("%d",&t);
for(int test = 1 ; test<= t; test++){
int hh , mm , tt , I;
int n;
scanf("%d",&n);
vector<long long > v;
long long temp;
char a;
for(int i = 0 ; i < n ; i++){
scanf("%d%c%d%c%d",&hh,&a ,&mm,&a,&tt);
temp = hh*3600 + mm*60 + tt;
v.push_back(temp);
}
scanf("%d",&I);
if(n==0){
printf("Case %d: 0\n",test);
continue;
}
sort(v.begin() , v.end());
queue<long long> q;
int j = 0 , len = -1;
q.push(v[j]);
while(j<n){
while(j< n && v[j] - q.front() < I){
j++;
q.push(v[j]);
}
int size = q.size() - 1;
len = max(len , size);
int temp = q.front();
q.pop();
while(!q.empty() && temp == q.front())
q.pop();
}
printf("Case %d: %d\n",test ,len);
}
}