Submission #233377

# Submission time Handle Problem Language Result Execution time Memory
233377 2020-05-20T10:50:51 Z NONAME Segway (COI19_segway) C++17
100 / 100
305 ms 1524 KB
#include <bits/stdc++.h>
#define sz(x) int(x.size())
#define in(x) freopen(x, "r", stdin)
#define out(x) freopen(x, "w", stdout)
#define N 100500
#define oo ll(1e16)
#define ft first
#define sd second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define el '\n'
#define elf endl
#define base ll(1e9 + 7)
using namespace std;
typedef long long ll;
typedef long double ld;

int n, m, a[N][3], up[N], tim[N];
vector <pair <int, int> > cur, nxt;
bool mk[N];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

//    in("input.txt");

    cin >> n;
    for (int i = 0; i < n; i++)
    for (int j = 0; j < 3; j++)
        cin >> a[i][j];

    cin >> m;

    for (int i = 0; i < m; i++) {
        int ps;
        cin >> ps;
        mk[ps] = 1;
    }

    for (int i = 0; i < n; i++)
        cur.pb(mp(0, i));

    for (int position = 0; position < 300; position++) {
        nxt.clear();
        sort(cur.begin(), cur.end());

        int cnt = 0;
        int lst = -1;
        for (int i = 0; i < n; i++) {
            int dst = cur[i].ft;
            int nm = cur[i].sd;

            if (dst != lst)
                cnt = i;
            lst = dst;

            if (mk[position] && up[nm] == 0)
                up[nm] = cnt % 20;

            if (up[nm] != 0) up[nm]--, dst++;
                else dst += a[nm][position / 100];

            nxt.pb(mp(dst, nm));
        }

        cur = nxt;
    }

    for (int i = 0; i < n; i++)
        tim[cur[i].sd] = cur[i].ft;

    for (int i = 0; i < n; i++)
        cout << tim[i] << el;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 13 ms 384 KB Output is correct
4 Correct 45 ms 640 KB Output is correct
5 Correct 292 ms 1524 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 6 ms 384 KB Output is correct
8 Correct 6 ms 384 KB Output is correct
9 Correct 7 ms 384 KB Output is correct
10 Correct 8 ms 384 KB Output is correct
11 Correct 7 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 13 ms 384 KB Output is correct
4 Correct 45 ms 640 KB Output is correct
5 Correct 292 ms 1524 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 6 ms 384 KB Output is correct
13 Correct 6 ms 384 KB Output is correct
14 Correct 7 ms 384 KB Output is correct
15 Correct 8 ms 384 KB Output is correct
16 Correct 7 ms 384 KB Output is correct
17 Correct 17 ms 384 KB Output is correct
18 Correct 29 ms 504 KB Output is correct
19 Correct 138 ms 1016 KB Output is correct
20 Correct 179 ms 1016 KB Output is correct
21 Correct 240 ms 1400 KB Output is correct
22 Correct 305 ms 1396 KB Output is correct
23 Correct 274 ms 1524 KB Output is correct