Submission #303421

# Submission time Handle Problem Language Result Execution time Memory
303421 2020-09-20T09:57:22 Z myungwoo Comparing Plants (IOI20_plants) C++17
14 / 100
4000 ms 5752 KB
#include <bits/stdc++.h>
#include "plants.h"
using namespace std;

#define MAXN 200005

int N, K, R[MAXN];
int A[MAXN];

void init(int K, vector<int> r)
{
	::K = K;
	assert(K+K > N && N <= 5000);
	N = r.size();
	for (int i=1;i<=N;i++) R[i] = r[i-1];
	for (int h=N;h;h--){
		auto find_highest = [&](){
			int cnt = 0;
			for (int i=1;i<=N+N;i++){
				int x = i > N ? i-N : i;
				if (R[x] == 0){
					if (cnt >= K-1) return x;
					cnt = 0;
				}
				else cnt++;
			}
			return 0;
		};
		int x = find_highest();
		assert(x != 0);
		A[x] = h; R[x] = -1;
		for (int i=1;i<K;i++){
			int t = x-i < 1 ? x-i+N : x-i;
			if (R[t] != -1) R[t]--;
		}
	}
}

int compare_plants(int x, int y)
{
	x++; y++;
	if (A[x] > A[y]) return 1;
	if (A[x] < A[y]) return -1;
	return 0; // can't reach here
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 416 KB Output is correct
4 Incorrect 1 ms 256 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 6 ms 384 KB Output is correct
7 Correct 170 ms 3320 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 6 ms 384 KB Output is correct
10 Correct 168 ms 3320 KB Output is correct
11 Correct 115 ms 3196 KB Output is correct
12 Correct 113 ms 3320 KB Output is correct
13 Correct 185 ms 3320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 6 ms 384 KB Output is correct
7 Correct 170 ms 3320 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 6 ms 384 KB Output is correct
10 Correct 168 ms 3320 KB Output is correct
11 Correct 115 ms 3196 KB Output is correct
12 Correct 113 ms 3320 KB Output is correct
13 Correct 185 ms 3320 KB Output is correct
14 Correct 1260 ms 3560 KB Output is correct
15 Execution timed out 4027 ms 5752 KB Time limit exceeded
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 75 ms 3192 KB Output is correct
4 Execution timed out 4073 ms 5504 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Incorrect 0 ms 256 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Incorrect 0 ms 256 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 416 KB Output is correct
4 Incorrect 1 ms 256 KB Output isn't correct
5 Halted 0 ms 0 KB -