Submission #767650

#TimeUsernameProblemLanguageResultExecution timeMemory
767650SanguineChameleonThe Big Prize (IOI17_prize)C++17
20 / 100
88 ms408 KiB
#include "prize.h"
#include <bits/stdc++.h>
using namespace std;

int find_best(int n) {
	int cur = 0;
	int cnt = 0;
	while (true) {
		cnt++;
		assert(cnt <= 10000);
		vector<int> res1 = ask(cur);
		if (res1[0] + res1[1] == 0) {
			return cur;
		}
		int lt = cur + 1;
		int rt = n - 2;
		while (lt <= rt) {
			int mt = (lt + rt) / 2;
			cnt++;
			assert(cnt <= 10000);
			vector<int> res2 = ask(mt);
			if (res2[0] + res2[1] == 0) {
				return mt;
			}
			if (res2[1] == res1[1]) {
				cur = mt;
				lt = mt + 1;
			}
			else {
				rt = mt - 1;
			}
		}
		cur++;
	}
	return -1;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...