Advertisement
Guest User

TV

a guest
Dec 8th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.93 KB | None | 0 0
  1. #include <fstream>
  2. using namespace std;
  3.  
  4. ifstream fin("tv.in");ofstream fout("tv.out");
  5. //ifstream fin("input");ofstream fout("output");
  6.  
  7. int k, n, maxx = 0, ans1, ans2;
  8. int dur, h, m, s;
  9. int mars[100005];
  10. int hs = 3600 * 24;
  11.  
  12. void afis(int nr) {
  13.     h = nr / 3600; nr -= h * 3600;
  14.     m = nr / 60; nr -= m * 60;
  15.     s = nr;
  16.     if (h < 10) {
  17.         fout << 0;
  18.     }
  19.     fout << h << ":";
  20.     if (m < 10) {
  21.         fout << 0;
  22.     }
  23.     fout << m << ":";
  24.     if (s < 10) {
  25.         fout << 0;
  26.     }
  27.     fout << s;
  28. }
  29.  
  30. int main() {
  31.     fin >> k;
  32.     fin >> n;
  33.     for (int i = 1; i <= n; i++) {
  34.         char c;
  35.         fin >> dur >> h >> c >> m >> c >> s;
  36.         mars[s + 60 * m + 3600 * h] += 1;
  37.         mars[s + 60 * m + 3600 * h + dur] -= 1;
  38.     }
  39.     ans1 = hs;
  40.     for (int i = 0; i < hs; i++) {
  41.         mars[i] = mars[i - 1] + mars[i];
  42.         if (mars[i] > maxx) {
  43.             maxx = mars[i];
  44.             ans2 = i;
  45.         }
  46.         if (mars[i]) {
  47.             ans1--;
  48.         }
  49.  
  50.     }
  51.  
  52.     if (k == 1) {
  53.         afis(ans1);
  54.     }
  55.     else {
  56.         afis(ans2);
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement