제출 #70282

#제출 시각아이디문제언어결과실행 시간메모리
70282E869120커다란 상품 (IOI17_prize)C++14
90 / 100
134 ms580 KiB
#include "prize.h"
#include <bits/stdc++.h>
using namespace std;

int find_best(int n) {
	int cx = 0;
	
	while (true) {
		vector<int> X1 = ask(cx);
		
		vector<int> X2 = ask(min(n - 1, cx + 1024));
		
		int L = cx, R = n, M, maxn = 0; if(X2 != X1) R = min(n, cx + 1024);
		for (int i = 0; i < 18; i++) {
			M = (L + R) / 2;
			vector<int> R1 = ask(min(n, M));
			if (R1[0] + R1[1] == 0) return M;
			if (X1 == R1) { L = M; maxn = max(maxn, M); }
			else { R = M; }
		}
		cx = maxn + 2;
	}
	return -1;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...