Submission #1192816

#TimeUsernameProblemLanguageResultExecution timeMemory
1192816MuhammetThe Big Prize (IOI17_prize)C++20
90 / 100
21 ms408 KiB
#include "bits/stdc++.h"
#include "prize.h"
// #include "grader.cpp"

using namespace std;

int find_best(int n) {
	int x = 0;
	vector <int> v = ask(x), v1, v2;
	while(1) {
		int l = x, r = n-1, k1 = (int(sqrt(n) / 2)), k = k1;
		if(v[0] + v[1] == 0) return x;
		while(x + k < n) {
			if(ask(k + x) == v) l = x + k;
			else {
				r = k + x;
				break;
			}
			k += k1;
		}
		while(l <= r) {
			int md = (l + r) / 2;
			v1 = ask(md);
			if(v1[0] + v1[1] == 0) return md;
			if(v1 == v) l = md+1;
			else r = md-1, x = md, v2 = v1;
		}
		v = v2;
	}

	assert(0);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...