Submission #1056791

# Submission time Handle Problem Language Result Execution time Memory
1056791 2024-08-13T11:17:24 Z phoenix The Big Prize (IOI17_prize) C++17
0 / 100
6 ms 5208 KB
#include "prize.h"
#include <bits/stdc++.h>

using namespace std;

const int N = 200200;
const int B = 450;

vector<int> arr[N];

vector<int> ASK(int p) {
	if (arr[p].empty())
		arr[p] = ask(p);
	return arr[p];	
}

int sum(int i) {
	return ASK(i)[0] + ASK(i)[1];
}

int find_best(int n) {
	int val = sum(0);
	
	for (int i = 0; i < min(n, B); i++) {
		if (!sum(i)) return i;
		val = max(val, sum(i));
	}
	int cnt = 0;
	for (int i = 0; i < B; i++) 
		cnt += (sum(i) < val);
	
	for (int it = B; it < n; it += B) {
		int rb = min(it + B - 1, n - 1), k = 0;
		if (sum(rb) == val && arr[rb][0] == cnt) 
			continue;
		while (rb >= it && sum(rb) < val) {
			k++;
			rb--;
		}
		int i = it, del = arr[rb][0] - cnt;
		while (i < rb && del) {
			while (i < rb && sum(i) < val) {
				if (!sum(i))
					return i;
				i++;
				del--;
				k++;
			}
			if (!del) break;
			int l = i, r = rb;
			while (r - l > 1) {
				int mid = (l + r) / 2;
				if (ASK(mid) == ASK(i)) 
					l = mid;
				else {
					if (!sum(mid))
						return mid;
					r = mid;
				}
			}
			i = r;
		}
		cnt += k;
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4952 KB Output is correct
2 Correct 4 ms 5136 KB Output is correct
3 Correct 6 ms 4952 KB Output is correct
4 Incorrect 5 ms 4952 KB answer is not correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 4 ms 5208 KB Output is correct
3 Correct 4 ms 4952 KB Output is correct
4 Incorrect 4 ms 4952 KB answer is not correct
5 Halted 0 ms 0 KB -