Submission #157795

# Submission time Handle Problem Language Result Execution time Memory
157795 2019-10-13T01:40:29 Z imyujin Segway (COI19_segway) C++17
100 / 100
198 ms 25948 KB
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 20010;
const int MAXM = 310;
const int MAXT = 50 * 300 + 10;

int A[MAXN][3], X[MAXM];
vector<int> tl[MAXT];
int cnt[MAXM];
int acc[MAXN], p[MAXN];
int ans[MAXN];

int calt(int x, int t, int pos) {
	if(acc[x] >= t + X[p[x]] - pos) return t + X[p[x]] - pos;
	int ans = max(acc[x], t);
	if(acc[x] > t) pos = pos + acc[x] - t;
	if(pos >= 200) return ans + (X[p[x]] - pos) * A[x][2];
	if(pos >= 100) {
		if(X[p[x]] <= 200) return ans + (X[p[x]] - pos) * A[x][1];
		return ans + (200 - pos) * A[x][1] + (X[p[x]] - 200) * A[x][2];
	}
	if(X[p[x]] <= 100) return ans + (X[p[x]] - pos) * A[x][0];
	if(X[p[x]] <= 200) return ans + (100 - pos) * A[x][0] + (X[p[x]] - 100) * A[x][1]; 
	return ans + (100 - pos) * A[x][0] + 100 * A[x][1] + (X[p[x]] - 200) * A[x][2];
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	int N, M;

	cin >> N;
	for(int i = 1; i <= N; i++) for(int j = 0; j < 3; j++) cin >> A[i][j];
	cin >> M;
	for(int i = 0; i < M; i++) cin >> X[i];

	sort(X, X + M);
	X[M] = 300;
	for(int i = 1; i <= N; i++) tl[calt(i, 0, 0)].push_back(i);
	for(int i = 0; i < MAXT; i++) {
		for(auto a : tl[i]) {
			if(p[a]++ == M) ans[a] = i;
			else {
				if(acc[a] <= i) acc[a] = i + cnt[p[a] - 1] % 20;
				tl[calt(a, i, X[p[a] - 1])].push_back(a);
			}
		}
		for(auto a : tl[i]) cnt[p[a] - 1]++;
	}

	for(int i = 1; i <= N; i++) cout << ans[i] << "\n";
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 632 KB Output is correct
2 Correct 2 ms 760 KB Output is correct
3 Correct 3 ms 760 KB Output is correct
4 Correct 4 ms 888 KB Output is correct
5 Correct 11 ms 1528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 632 KB Output is correct
2 Correct 2 ms 632 KB Output is correct
3 Correct 2 ms 760 KB Output is correct
4 Correct 2 ms 760 KB Output is correct
5 Correct 2 ms 760 KB Output is correct
6 Correct 3 ms 760 KB Output is correct
7 Correct 1 ms 760 KB Output is correct
8 Correct 3 ms 760 KB Output is correct
9 Correct 3 ms 888 KB Output is correct
10 Correct 3 ms 888 KB Output is correct
11 Correct 5 ms 1016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 632 KB Output is correct
2 Correct 2 ms 760 KB Output is correct
3 Correct 3 ms 760 KB Output is correct
4 Correct 4 ms 888 KB Output is correct
5 Correct 11 ms 1528 KB Output is correct
6 Correct 2 ms 632 KB Output is correct
7 Correct 2 ms 632 KB Output is correct
8 Correct 2 ms 760 KB Output is correct
9 Correct 2 ms 760 KB Output is correct
10 Correct 2 ms 760 KB Output is correct
11 Correct 3 ms 760 KB Output is correct
12 Correct 1 ms 760 KB Output is correct
13 Correct 3 ms 760 KB Output is correct
14 Correct 3 ms 888 KB Output is correct
15 Correct 3 ms 888 KB Output is correct
16 Correct 5 ms 1016 KB Output is correct
17 Correct 3 ms 760 KB Output is correct
18 Correct 20 ms 3960 KB Output is correct
19 Correct 36 ms 5368 KB Output is correct
20 Correct 14 ms 1784 KB Output is correct
21 Correct 65 ms 9436 KB Output is correct
22 Correct 142 ms 19324 KB Output is correct
23 Correct 198 ms 25948 KB Output is correct