G2A Many GEOs
SHARE
TWEET

Untitled

a guest Jul 1st, 2015 360 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. Contest : CF GYM
  3. */
  4.  
  5. #include<bits/stdc++.h>
  6. using namespace std;
  7.  
  8. typedef long long int LL;
  9.  
  10. #define inp_s     ios_base::sync_with_stdio(false);cin.tie(0)
  11. #define DRT()     int test_case;cin>>test_case;while(test_case--)
  12.  
  13. #define VI        vector<int>
  14. #define VS        vector<string>
  15. #define VLL       vector<LL>
  16. #define PII       pair<int,int>
  17.  
  18. #define all(c)    c.begin(),c.end()
  19. #define sz(c)     c.size()
  20. #define clr(c)    c.clear()
  21. #define pb        push_back
  22. #define mp        make_pair
  23.  
  24. #define GI(x)     scanf("%d",&x)
  25. #define endn    "\n"
  26.  
  27. #define FOR(i,a,b)      for(int i=a;i<b;i++)
  28. #define RFOR(i,a,b)     for(int i=b-1;i>=a;i--)
  29.  
  30. #define gcd(a,b)  __gcd(a,b)
  31. #define MOD       1000000007
  32. #define EPS       1E-10
  33. #define PI      acos(-1)
  34.  
  35. #define CASE(x)   cout << "Case #" << x << ": ";
  36.  
  37. LL getTime(string x)
  38. {
  39.     int hh = (x[0] - '0') * 10 + x[1] - '0';
  40.     int mm = (x[3] - '0') * 10 + x[4] - '0';
  41.     int ss = (x[6] - '0') * 10 + x[7] - '0';
  42.     LL ret = ss + (mm*60) + (hh*3600);
  43.     return ret;
  44. }
  45.  
  46. int main()
  47. {
  48.     inp_s;
  49.     int n;
  50.     cin >> n;
  51.     VLL arr(n);
  52.     FOR(i,0,n)
  53.     {
  54.         string s;
  55.         cin >> s;
  56.         arr[i] = getTime(s);
  57.     }
  58.     sort(all(arr));
  59.     int ans = 1;
  60.     priority_queue < LL , VLL , greater<LL> > pq;
  61.     pq.push(arr[0] + 900);
  62.     FOR(i,1,n)
  63.     {
  64.         LL minFree = pq.top();
  65.         LL answer_min = arr[i];
  66.         LL answer_max = arr[i] + 3 * 60 * 60 - 900;
  67.         if(minFree > answer_max)
  68.         {
  69.             ans += 1;
  70.             pq.push(answer_min + 900);
  71.         }
  72.         else if(minFree < answer_min)
  73.         {
  74.             pq.pop();
  75.             pq.push(answer_min + 900);
  76.         }
  77.         else
  78.         {
  79.             pq.pop();
  80.             pq.push(minFree + 900);
  81.         }
  82.     }
  83.  
  84.     cout << ans << endl;
  85.     return 0;
  86. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top