Submission #558390

# Submission time Handle Problem Language Result Execution time Memory
558390 2022-05-07T08:19:08 Z Yazan_Alattar Segway (COI19_segway) C++14
100 / 100
580 ms 1928 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define all(x) x.begin(), x.end()
const int M = 100007;
const ll inf = 2e9;
const ll mod = 1e9 + 7;
const double pi = acos(-1);
const double eps = 1e-6;
const int dx[] = {0, -1, 0, 1}, dy[] = {1, 0, -1, 0};
const int block = 320;

ll n, q, have[M], timer[M], a[M][3];
bool vist[M];

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    for(int i = 1; i <= n; ++i) for(int j = 0; j < 3; ++j) cin >> a[i][j];

    cin >> q;
    for(int i = 1; i <= q; ++i){
        int x;
        cin >> x;
        vist[x] = 1;
    }

    for(int m = 0; m < 300; ++m){
        if(vist[m]){
            vector < pair <int,int> > v;
            for(int i = 1; i <= n; ++i) v.pb({timer[i], i});
            sort(all(v), greater < pair <int,int> > ());

            int cnt = 0;
            for(int i = v.size() - 1; i >= 0; --i){
                while(v.back().F < v[i].F) v.pop_back(), ++cnt;
                if(!have[v[i].S]) have[v[i].S] = cnt % 20;
            }
        }

        for(int i = 1; i <= n; ++i){
            if(have[i]){
                --have[i];
                ++timer[i];
            }
            else timer[i] += a[i][m / 100];
        }
    }

    for(int i = 1; i <= n; ++i) cout << timer[i] << endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
5 Correct 13 ms 1572 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 4 ms 328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 2 ms 468 KB Output is correct
5 Correct 13 ms 1572 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 4 ms 328 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 44 ms 348 KB Output is correct
19 Correct 82 ms 960 KB Output is correct
20 Correct 21 ms 1100 KB Output is correct
21 Correct 158 ms 1296 KB Output is correct
22 Correct 408 ms 1928 KB Output is correct
23 Correct 580 ms 1776 KB Output is correct