Advertisement
Guest User

1

a guest
Oct 17th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.06 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. queue <int> a, b;
  6. int ans[101];
  7.  
  8. int main()
  9. {
  10.     int i, k, n, m, h, c, kol, ch;
  11.     cin >> n;
  12.     ans[0] = 0;
  13.     ch = -100;
  14.     for (i = 1; i <= n; i++)
  15.     {
  16.         cin >> h >> m >> kol;
  17.         c = h * 60 + m;
  18.         while (!a.empty() && a.front() + 20 <= c)
  19.         {
  20.             k = b.front();
  21.             if (a.front() <= ch)
  22.                 ans[k] = ch + 20;
  23.             else
  24.                 ans[k] = a.front() + 20;
  25.             ch = ans[k];
  26.             b.pop();
  27.             a.pop();
  28.         }
  29.         if (kol < a.size())
  30.             ans[i] = c;
  31.         else
  32.         {
  33.             a.push(c);
  34.             b.push(i);
  35.         }
  36.     }
  37.     ch = -100;
  38.     while (!a.empty())
  39.     {
  40.         k = b.front();
  41.         if (a.front() <= ch)
  42.             ans[k] = ch + 20;
  43.         else
  44.             ans[k] = a.front() + 20;
  45.         ch = ans[k];
  46.         b.pop();
  47.         a.pop();
  48.     }
  49.     for (i = 1; i <= n; i++)
  50.         cout << ans[i] / 60 << " " << ans[i] % 60 << endl;
  51.     return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement