Submission #331370

# Submission time Handle Problem Language Result Execution time Memory
331370 2020-11-28T07:20:42 Z dolphingarlic Segway (COI19_segway) C++14
100 / 100
161 ms 6380 KB
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

int a[20000], b[20000], c[20000], cnt[301], pos[20000], ans[20000], boost[20000];
vector<int> riders[51];
bool to_check[301];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i] >> c[i];
        riders[a[i]].push_back(i);
    }
    int m;
    cin >> m;
    while (m--) {
        int d;
        cin >> d;
        to_check[d] = true;
    }
    int now = 0;
    while (cnt[300] < n) {
        now++;
        for (int i : riders[now % 51]) {
            pos[i]++;
            if (to_check[pos[i]] && !boost[i]) boost[i] = cnt[pos[i]] % 20;

            if (pos[i] == 300) ans[i] = now;
            else if (boost[i]) {
                boost[i]--;
                riders[(now + 1) % 51].push_back(i);
            } else {
                int nxt;
                if (pos[i] < 100) nxt = (now + a[i]) % 51;
                else if (pos[i] < 200) nxt = (now + b[i]) % 51;
                else nxt = (now + c[i]) % 51;
                riders[nxt].push_back(i);
            }
        }
        for (int i : riders[now % 51]) cnt[pos[i]]++;
        riders[now % 51].clear();
    }
    for (int i = 0; i < n; i++) cout << ans[i] << '\n';
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 2 ms 492 KB Output is correct
3 Correct 6 ms 492 KB Output is correct
4 Correct 24 ms 748 KB Output is correct
5 Correct 161 ms 2924 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 2 ms 364 KB Output is correct
9 Correct 2 ms 364 KB Output is correct
10 Correct 3 ms 364 KB Output is correct
11 Correct 2 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 2 ms 492 KB Output is correct
3 Correct 6 ms 492 KB Output is correct
4 Correct 24 ms 748 KB Output is correct
5 Correct 161 ms 2924 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 2 ms 364 KB Output is correct
14 Correct 2 ms 364 KB Output is correct
15 Correct 3 ms 364 KB Output is correct
16 Correct 2 ms 492 KB Output is correct
17 Correct 7 ms 492 KB Output is correct
18 Correct 11 ms 876 KB Output is correct
19 Correct 58 ms 1704 KB Output is correct
20 Correct 79 ms 1644 KB Output is correct
21 Correct 90 ms 2560 KB Output is correct
22 Correct 117 ms 3948 KB Output is correct
23 Correct 99 ms 6380 KB Output is correct