답안 #611502

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
611502 2022-07-29T05:20:09 Z 이동현(#8500) Segway (COI19_segway) C++17
100 / 100
205 ms 34420 KB
#include <bits/stdc++.h>

using namespace std;

const int NS = (int)2e4 + 4;

int n, m;
int a[NS][3];
int t[NS], pos[NS], ex[304], fast[NS];
vector<int> que[300 * 300 + 4];

int tr[304];
void push(int x, int val){++x;for(int i = x; i < 304; i += (i & -i)){tr[i] += val;}}
int get(int x){++x;int rv = 0; for(int i = x; i > 0; i -= (i & -i)){rv += tr[i];} return rv;}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < 3; ++j){
            cin >> a[i][j];
        }
        que[a[i][0]].push_back(i);
        t[i] = a[i][0];
        push(0, 1);
    }
    cin >> m;
    for(int i = 0; i < m; ++i){
        int x; cin >> x;
        ex[x] = 1;
    }
    for(int i = 0; i < 300 * 300 + 4; ++i){
        for(int j = 0; j < (int)que[i].size(); ++j){
            int id = que[i][j];
            if(pos[id] + 1 < 300 && !fast[id] && ex[pos[id] + 1]){
                fast[id] = (get(300) - get(pos[id])) % 20;
            }
        }
        for(int j = 0; j < (int)que[i].size(); ++j){
            int id = que[i][j];
            if(pos[id] == 299) continue;
            push(pos[id], -1), push(pos[id] + 1, 1);
            ++pos[id];
            if(fast[id]) t[id] += 1, --fast[id];
            else{
                if(pos[id] < 100) t[id] += a[id][0];
                else if(pos[id] < 200) t[id] += a[id][1];
                else t[id] += a[id][2];
            }
            que[t[id]].push_back(id);
        }
    }
    for(int i = 0; i < n; ++i){
        cout << t[i] << '\n';
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2388 KB Output is correct
2 Correct 5 ms 2772 KB Output is correct
3 Correct 11 ms 3924 KB Output is correct
4 Correct 33 ms 7628 KB Output is correct
5 Correct 205 ms 34420 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2388 KB Output is correct
2 Correct 2 ms 2516 KB Output is correct
3 Correct 3 ms 2388 KB Output is correct
4 Correct 3 ms 2388 KB Output is correct
5 Correct 3 ms 2516 KB Output is correct
6 Correct 3 ms 2516 KB Output is correct
7 Correct 5 ms 2644 KB Output is correct
8 Correct 5 ms 2772 KB Output is correct
9 Correct 7 ms 2772 KB Output is correct
10 Correct 7 ms 2908 KB Output is correct
11 Correct 5 ms 2900 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2388 KB Output is correct
2 Correct 5 ms 2772 KB Output is correct
3 Correct 11 ms 3924 KB Output is correct
4 Correct 33 ms 7628 KB Output is correct
5 Correct 205 ms 34420 KB Output is correct
6 Correct 2 ms 2388 KB Output is correct
7 Correct 2 ms 2516 KB Output is correct
8 Correct 3 ms 2388 KB Output is correct
9 Correct 3 ms 2388 KB Output is correct
10 Correct 3 ms 2516 KB Output is correct
11 Correct 3 ms 2516 KB Output is correct
12 Correct 5 ms 2644 KB Output is correct
13 Correct 5 ms 2772 KB Output is correct
14 Correct 7 ms 2772 KB Output is correct
15 Correct 7 ms 2908 KB Output is correct
16 Correct 5 ms 2900 KB Output is correct
17 Correct 15 ms 4180 KB Output is correct
18 Correct 24 ms 5896 KB Output is correct
19 Correct 93 ms 16336 KB Output is correct
20 Correct 118 ms 21368 KB Output is correct
21 Correct 156 ms 25116 KB Output is correct
22 Correct 202 ms 29764 KB Output is correct
23 Correct 174 ms 27484 KB Output is correct