JuliaMelkozerova

HW2C

Mar 11th, 2020
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <vector>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     int N;
  10.     cin >> N;
  11.     vector <int> a(86401,0);
  12.     int h1, m1, s1, h2, m2, s2;
  13.     int input_in, input_out;
  14.    
  15.     for (int i = 0; i < N; i++) {
  16.         scanf("%d:%d:%d %d:%d:%d", &h1, &m1, &s1, &h2, &m2, &s2);
  17.         input_in = 3600*h1 + 60*m1 + s1;
  18.         input_out = 3600*h2 + 60*m2 + s2;
  19.        
  20.         a[input_in] += 1;
  21.         a[input_out + 1] -= 1;
  22.     }
  23.    
  24.     int max = 0;
  25.     int tmp = 0;
  26.     for (int i = 0; i < 86400; i++) {
  27.         tmp += a[i];
  28.         if (tmp > max) {
  29.             max = tmp;
  30.         }
  31.     }
  32.     cout << max;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment