Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- queue <int> a, b;
- int ans[101];
- int main()
- {
- int i, k, n, m, h, c, kol, ch;
- cin >> n;
- ans[0] = 0;
- ch = -100;
- for (i = 1; i <= n; i++)
- {
- cin >> h >> m >> kol;
- c = h * 60 + m;
- while (!a.empty() && a.front() + 20 <= c)
- {
- k = b.front();
- if (a.front() <= ch)
- ans[k] = ch + 20;
- else
- ans[k] = a.front() + 20;
- ch = ans[k];
- b.pop();
- a.pop();
- }
- if (kol < a.size())
- ans[i] = c;
- else
- {
- a.push(c);
- b.push(i);
- }
- }
- ch = -100;
- while (!a.empty())
- {
- k = b.front();
- if (a.front() <= ch)
- ans[k] = ch + 20;
- else
- ans[k] = a.front() + 20;
- ch = ans[k];
- b.pop();
- a.pop();
- }
- for (i = 1; i <= n; i++)
- cout << ans[i] / 60 << " " << ans[i] % 60 << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement