Submission #234772

# Submission time Handle Problem Language Result Execution time Memory
234772 2020-05-25T14:03:22 Z amoo_safar Segway (COI19_segway) C++14
100 / 100
452 ms 1528 KB
#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'

using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

const ll Mod = 1000000007LL;
const int N = 2e4 + 10;
const ll Inf = 2242545357980376863LL;
const ll Log = 30;

bool acc[310];
int n;
int s1[N], s2[N], s3[N], sn[N];
int rm[N];
int wh[N], rmt[N], pas[N], ans[N];

int Speed(int i){
	if(rm[i]) return 1;
	return sn[i];
}
vector<int> P;

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> s1[i] >> s2[i] >> s3[i];
	int m;
	cin >> m;
	int pos;
	for(int i = 0; i < m; i++){
		cin >> pos;
		acc[pos] = true;
	}
	for(int i = 1; i <= n; i++) sn[i] = s1[i], rmt[i] = Speed(i);

	int T = 0;
	while(true){
		int del = *min_element(rmt + 1, rmt + n + 1);
		if(del > 50) break;
		for(auto x : P)
			pas[x] ++;
		T += del;
		P.clear();
		for(int i = 1; i <= n; i++){
			rmt[i] -= del;
			if(rmt[i] == 0){
				if(rm[i]) rm[i] --;
				wh[i] ++;
				if(acc[wh[i]] && rm[i] == 0){
					rm[i] += pas[wh[i]] % 20;
				}
				
				if(wh[i] == 100) sn[i] = s2[i];
				if(wh[i] == 200) sn[i] = s3[i];
				if(wh[i] == 300) sn[i] = 1e9;
				rmt[i] = Speed(i);
				P.pb(wh[i]);
				if(wh[i] == 300) ans[i] = T;
			}
		}
	}
	for(int i = 1; i <= n; i++) cout << ans[i] << '\n';
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 8 ms 384 KB Output is correct
3 Correct 20 ms 384 KB Output is correct
4 Correct 68 ms 512 KB Output is correct
5 Correct 452 ms 1144 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 5 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 7 ms 384 KB Output is correct
9 Correct 8 ms 384 KB Output is correct
10 Correct 9 ms 384 KB Output is correct
11 Correct 6 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 8 ms 384 KB Output is correct
3 Correct 20 ms 384 KB Output is correct
4 Correct 68 ms 512 KB Output is correct
5 Correct 452 ms 1144 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 5 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 7 ms 384 KB Output is correct
14 Correct 8 ms 384 KB Output is correct
15 Correct 9 ms 384 KB Output is correct
16 Correct 6 ms 384 KB Output is correct
17 Correct 26 ms 384 KB Output is correct
18 Correct 19 ms 512 KB Output is correct
19 Correct 129 ms 800 KB Output is correct
20 Correct 217 ms 896 KB Output is correct
21 Correct 222 ms 1084 KB Output is correct
22 Correct 252 ms 1400 KB Output is correct
23 Correct 95 ms 1528 KB Output is correct