Submission #234558

# Submission time Handle Problem Language Result Execution time Memory
234558 2020-05-24T13:40:35 Z shayan_p Segway (COI19_segway) C++14
100 / 100
182 ms 61432 KB
// Never let them see you bleed...

#include<bits/stdc++.h>

#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

const int maxn = 2e4 + 10, maxL = 310, maxS = 55, maxT = maxL * maxS, inf = 1e9;

int a[maxn][3], ans[maxn], cnt[maxL], suf[maxL];
int super[maxn], supercnt[maxn];
bool is[maxL];
vector<pii> v[maxT];

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

    fill(super, super+maxn, -inf);
    
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
	cin >> a[i][0] >> a[i][1] >> a[i][2];
	v[a[i][0]].PB({i, 1});
    }
    int q;
    cin >> q;
    while(q--){
	int x;
	cin >> x;
	is[x] = 1;		 
    }
    cnt[0] = n;
    for(int t = 0; t < maxT; t++){	
	for(int i = maxL-1; i >= 0; i--)
	    suf[i] = suf[i+1] + cnt[i];
	for(pii p : v[t]){
	    if(p.S == 300){
		ans[p.F] = t;
		continue;
	    }
	    if(is[p.S]){
		int T = suf[p.S] % 20;
		if(super[p.F] + supercnt[p.F] <= t)
		    super[p.F] = t, supercnt[p.F] = T;
	    }
	    cnt[p.S-1]--;
	    cnt[p.S]++;
	    if(super[p.F] + supercnt[p.F] > t)
		v[t + 1].PB({p.F, p.S+1});
	    else
		v[t + (p.S < 100 ? a[p.F][0] : (p.S < 200 ? a[p.F][1] : a[p.F][2]))].PB({p.F, p.S+1});
	}
    }
    for(int i = 0; i < n; i++){
	cout << ans[i] << "\n";
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 20 ms 896 KB Output is correct
2 Correct 23 ms 1536 KB Output is correct
3 Correct 29 ms 3712 KB Output is correct
4 Correct 48 ms 11128 KB Output is correct
5 Correct 182 ms 61432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 896 KB Output is correct
2 Correct 20 ms 896 KB Output is correct
3 Correct 21 ms 896 KB Output is correct
4 Correct 20 ms 896 KB Output is correct
5 Correct 21 ms 1024 KB Output is correct
6 Correct 20 ms 1024 KB Output is correct
7 Correct 22 ms 1152 KB Output is correct
8 Correct 22 ms 1408 KB Output is correct
9 Correct 23 ms 1664 KB Output is correct
10 Correct 24 ms 1920 KB Output is correct
11 Correct 22 ms 1792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 896 KB Output is correct
2 Correct 23 ms 1536 KB Output is correct
3 Correct 29 ms 3712 KB Output is correct
4 Correct 48 ms 11128 KB Output is correct
5 Correct 182 ms 61432 KB Output is correct
6 Correct 20 ms 896 KB Output is correct
7 Correct 20 ms 896 KB Output is correct
8 Correct 21 ms 896 KB Output is correct
9 Correct 20 ms 896 KB Output is correct
10 Correct 21 ms 1024 KB Output is correct
11 Correct 20 ms 1024 KB Output is correct
12 Correct 22 ms 1152 KB Output is correct
13 Correct 22 ms 1408 KB Output is correct
14 Correct 23 ms 1664 KB Output is correct
15 Correct 24 ms 1920 KB Output is correct
16 Correct 22 ms 1792 KB Output is correct
17 Correct 32 ms 4352 KB Output is correct
18 Correct 33 ms 7504 KB Output is correct
19 Correct 78 ms 26360 KB Output is correct
20 Correct 103 ms 36600 KB Output is correct
21 Correct 116 ms 42376 KB Output is correct
22 Correct 133 ms 51704 KB Output is correct
23 Correct 124 ms 49652 KB Output is correct