Advertisement
Zeinab_Hamdy

acc

Apr 13th, 2023
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.75 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define ull unsigned ll
  5. #define nl "\n"
  6. #define sz(x) int(x.size())
  7. #define NumOfDigit(w) log10(w) + 1
  8. #define fill(arr, val)  memset(arr, val , sizeof(arr))
  9. #define PI 3.141592654
  10. #define ceil(w, m) (((w) / (m)) + ((w) % (m) ? 1 : 0))
  11. #define all(v) v.begin(), v.end()
  12. #define rall(v) v.rbegin(), v.rend()
  13. #define fi first
  14. #define se second
  15. #define cin(v) for (auto&i:v) cin >> i;
  16. #define cout(v) for (auto&i:v) cout << i << " ";
  17. #define fixed(n) fixed << setprecision(n)
  18. //#define MOD  1e9 + 7
  19.  
  20.  
  21. void IO(){
  22.     ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
  23. }
  24. void files(){
  25.     //freopen("filename.in" , "r" ,stdin);
  26.             #ifndef ONLINE_JUDGE
  27.               freopen("input.txt", "r", stdin);  freopen("output.txt", "w", stdout);
  28.             #endif
  29. }
  30.  
  31.  
  32. void solve(){
  33. // 24 * 60 * 60 = 86400;
  34.  
  35. vector < ll >  v(86500);
  36. ll n ;
  37. cin >> n ;
  38. while(n--){
  39.     string l ,r ;
  40.     cin >> l >> r;
  41.     ll t1= (l[0]-'0') *10  + (l[1]-'0'),  s1= (l[3]-'0') *10  + (l[4]-'0');
  42.     t1 = t1 * 60 * 60 + s1 * 60;
  43.    
  44.     ll t2 =  (r[0]-'0') *10  + (r[1]-'0') , s2= (r[3]-'0') *10  + (r[4]-'0');
  45.    
  46.     t2 = t2 * 60 * 60 + s2 * 60;
  47.    
  48.     v[t1]++;
  49.     v[t2]--;
  50. }
  51.  
  52.  
  53. for(int i=1;i<=86500 ;i++){
  54.     v[i]+=v[i-1];
  55. }
  56.  
  57. int q; cin >> q;
  58. while(q--){
  59.     string t ;
  60.     cin >> t;
  61.    
  62.      ll t1= (t[0]-'0') *10  + (t[1]-'0') , s1= (t[3]-'0') *10  + (t[4]-'0');
  63.     t1 = t1 * 60 * 60 + s1 * 60;
  64.    
  65.     cout << v[t1+1] << nl;
  66.    
  67. }
  68.  
  69. }
  70. int main(){
  71.                  IO();       //  files();
  72.  
  73.     int testCase=1;  // one test case
  74.       //  cin >> testCase ;      
  75.  while(testCase--)
  76.         solve();  // my code
  77.        
  78.     return 0;
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement