Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <queue>
- using namespace std;
- int main() {
- int n;
- cin >> n;
- queue<pair<int, int>> q;
- int current_time = 0;
- vector<int> ans(n);
- auto update_answer = [&]() {
- current_time = max(q.front().first + 20, current_time + 20);
- ans[q.front().second] = current_time;
- };
- for (int i = 0; i < n; ++i) {
- int h, m, p;
- cin >> h >> m >> p;
- int time = h * 60 + m;
- while (q.size() > 0 && current_time <= time) {
- q.pop();
- if (q.size() > 0) {
- update_answer();
- }
- }
- if (q.size() <= p) {
- q.emplace(time, i);
- if (q.size() == 1) {
- update_answer();
- }
- } else {
- ans[i] = time;
- }
- }
- while (q.size() > 0) {
- q.pop();
- if (q.size() > 0) {
- update_answer();
- }
- }
- for (int i = 0; i < n; ++i) {
- cout << ans[i] / 60 << " " << ans[i] % 60 << "\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement