Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int n, a, d;
- int main() {
- cin.tie(0)->sync_with_stdio(0);
- cin >> n;
- bool waiting = false;
- int last = 0, curr = -1;
- for (int i = 0; i < n; ++i) {
- cin >> a >> d;
- if (a > last and waiting) {
- last += 10;
- curr ^= 1;
- waiting = false;
- }
- if (a > last) {
- last = a + 10;
- curr = d;
- } else if (a < last) {
- if (curr != d) {
- waiting = true;
- } else {
- last = a + 10;
- }
- }
- }
- if (waiting) last += 10;
- cout << last << '\n';
- }
- /*
- 6
- 5 0
- 9 0
- 10 1
- 11 1
- 12 0
- 15 0
- R = 35
- 7
- 5 0
- 9 0
- 10 1
- 11 1
- 12 0
- 15 0
- 24 1
- R = 35
- 7
- 5 0
- 9 0
- 10 1
- 11 1
- 12 0
- 15 0
- 26 1
- R = 36
- 4
- 5 0
- 7 1
- 14 0
- 15 0
- R = 35
- 4
- 5 0
- 8 0
- 10 1
- 13 0
- R = 33
- */
Add Comment
Please, Sign In to add comment