Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Contest : CF GYM
- */
- #include<bits/stdc++.h>
- using namespace std;
- typedef long long int LL;
- #define inp_s ios_base::sync_with_stdio(false);cin.tie(0)
- #define DRT() int test_case;cin>>test_case;while(test_case--)
- #define VI vector<int>
- #define VS vector<string>
- #define VLL vector<LL>
- #define PII pair<int,int>
- #define all(c) c.begin(),c.end()
- #define sz(c) c.size()
- #define clr(c) c.clear()
- #define pb push_back
- #define mp make_pair
- #define GI(x) scanf("%d",&x)
- #define endn "\n"
- #define FOR(i,a,b) for(int i=a;i<b;i++)
- #define RFOR(i,a,b) for(int i=b-1;i>=a;i--)
- #define gcd(a,b) __gcd(a,b)
- #define MOD 1000000007
- #define EPS 1E-10
- #define PI acos(-1)
- #define CASE(x) cout << "Case #" << x << ": ";
- LL getTime(string x)
- {
- int hh = (x[0] - '0') * 10 + x[1] - '0';
- int mm = (x[3] - '0') * 10 + x[4] - '0';
- int ss = (x[6] - '0') * 10 + x[7] - '0';
- LL ret = ss + (mm*60) + (hh*3600);
- return ret;
- }
- int main()
- {
- inp_s;
- int n;
- cin >> n;
- VLL arr(n);
- FOR(i,0,n)
- {
- string s;
- cin >> s;
- arr[i] = getTime(s);
- }
- sort(all(arr));
- int ans = 1;
- priority_queue < LL , VLL , greater<LL> > pq;
- pq.push(arr[0] + 900);
- FOR(i,1,n)
- {
- LL minFree = pq.top();
- LL answer_min = arr[i];
- LL answer_max = arr[i] + 3 * 60 * 60 - 900;
- if(minFree > answer_max)
- {
- ans += 1;
- pq.push(answer_min + 900);
- }
- else if(minFree < answer_min)
- {
- pq.pop();
- pq.push(answer_min + 900);
- }
- else
- {
- pq.pop();
- pq.push(minFree + 900);
- }
- }
- cout << ans << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement