Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.17 KB | None | 0 0
  1. //
  2. //  main.cpp
  3. //  GenirationThePassOnOlymp
  4. //
  5. //  Created by Kadir Kadyrov on 9/23/19.
  6. //  Copyright © 2019 Kadir Kadyrov. All rights reserved.
  7. //
  8.  
  9. #include <iostream>
  10. #include <string>
  11. #include <algorithm>
  12. #include <vector>
  13. #include <set>
  14. #include <cmath>
  15. #include <string.h>
  16. #include <cstdlib>
  17. #include <fstream>
  18. #include <map>
  19. #define N 101
  20. #define MOD 1000000007
  21. #define LOCAL
  22. #undef LOCAL
  23.  
  24. using namespace std;
  25.  
  26. int st[25], fn[25];
  27.  
  28. int main () {
  29.    
  30. #ifndef LOCAL
  31.     freopen("shop.in", "r", stdin);
  32.     freopen("shop.out", "w", stdout);
  33. #endif
  34.    
  35.     int n;
  36.     cin >> n;
  37.    
  38.     for(int i = 0; i < n; i++) {
  39.         int start, finish;
  40.         cin >> start >> finish;
  41.         if(start >= finish) {
  42.             fn[24]++;
  43.             st[start]++;
  44.             st[0]++;
  45.             fn[finish]++;
  46.         } else {
  47.             fn[finish]++;
  48.             st[start]++;
  49.         }
  50.     }
  51.    
  52.     int num, ans;
  53.     num = ans = 0;
  54.     for(int time = 0; time <= 24; time++) {
  55.         num += st[time];
  56.         num -= fn[time];
  57.        
  58.         if(num == n)
  59.             ans++;
  60.     }
  61.    
  62.     cout << ans << endl;
  63.    
  64.    
  65.    
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement