Submission #1192772

#TimeUsernameProblemLanguageResultExecution timeMemory
1192772MuhammetThe Big Prize (IOI17_prize)C++20
20 / 100
23 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, k = (x + int(sqrt(n) / 2));
		if(v[0] + v[1] == 0) return x;
		if(k < n) {
			if(ask(k) == v) l = k;
			else r = k;
		}
		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...