Submission #1083676

# Submission time Handle Problem Language Result Execution time Memory
1083676 2024-09-03T19:52:56 Z fv3 Comparing Plants (IOI20_plants) C++17
14 / 100
4000 ms 9552 KB
#include "plants.h"
#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;

int K, N;

vector<int> R;

bool check(int s)
{
	int cnt = 0;
	for (int i = s - 1; i >= 0 && cnt < K - 1; i--, cnt++)
		if (!R[i]) return false;
	for (int i = N - 1; cnt < K - 1; i--, cnt++)
		if (!R[i]) return false;

	cnt = 0;
	for (int i = s - 1; i >= 0 && cnt < K - 1; i--, cnt++)
		R[i]--;
	for (int i = N - 1; cnt < K - 1; i--, cnt++)
		R[i]--;

	return true;
}

vector<int> H;
void init(int k, vector<int> r) 
{
	R = r; K = k;
	N = (int)r.size();

	// Find ordering in O(N²)
	H = vector<int>(N);
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < N; j++)
		{
			if (R[j]) continue;
			if (check(j))
			{
				H[j] = N - i;
				R[j] = INF;
				break;
			}
		}
	}
}

int compare_plants(int x, int y) 
{
	if (H[x] > H[y])
		return 1;
	return -1;
}

#ifdef TEST
#include "grader.cpp"
#endif
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 3 ms 344 KB Output is correct
7 Correct 67 ms 5204 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 3 ms 544 KB Output is correct
10 Correct 68 ms 5008 KB Output is correct
11 Correct 54 ms 4944 KB Output is correct
12 Correct 56 ms 5200 KB Output is correct
13 Correct 66 ms 5204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 3 ms 344 KB Output is correct
7 Correct 67 ms 5204 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 3 ms 544 KB Output is correct
10 Correct 68 ms 5008 KB Output is correct
11 Correct 54 ms 4944 KB Output is correct
12 Correct 56 ms 5200 KB Output is correct
13 Correct 66 ms 5204 KB Output is correct
14 Correct 426 ms 5584 KB Output is correct
15 Execution timed out 4030 ms 9552 KB Time limit exceeded
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 35 ms 4956 KB Output is correct
4 Execution timed out 4025 ms 8784 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -