Submission #234595

#TimeUsernameProblemLanguageResultExecution timeMemory
234595pedy4000Segway (COI19_segway)C++14
100 / 100
208 ms1024 KiB
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

const int N = 2e4 + 8;
int n, m;
bool mark[N];
int speed[N][3];
int val[N];
int Arr[N];
int upd[N];

bool cmp(int a, int b) {
	return val[a] < val[b];
}

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

	cin >> m;
	while (m--) {
		int a;
		cin >> a;
		mark[a] = true;
	}

	for (int i = 0; i < n; i++)
		Arr[i] = i;

	for (int i = 1; i <= 300; i++) {
		for (int j = 0; j < n; j++) {
			if (upd[j]) {
				upd[j]--;
				val[j]++;
			}
			else
				val[j] += speed[j][(i - 1) / 100];
		}

		if (mark[i]) {
			sort(Arr, Arr + n, cmp);
			int nxt = 0;
			for (int j = 0; j < n; j++) {
				if (j && val[Arr[j - 1]] != val[Arr[j]])
					nxt = j;
				if (upd[Arr[j]] == 0)
					upd[Arr[j]] = nxt % 20;
			}
		}
	}

	for (int i = 0; i < n; i++)
		cout << val[i] << "\n";
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...