Submission #1043008

#TimeUsernameProblemLanguageResultExecution timeMemory
1043008Mr_HusanboyThe Big Prize (IOI17_prize)C++17
20 / 100
3040 ms512 KiB
#include "prize.h"
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ff first
#define ss second
#define all(a) (a).begin(), (a).end()

template<typename T>
int len(T &a){
	return a.size();
}
int _q = 0;

int find_best(int n) {
	// if(n <= 5000){
	// 	for(int i = 0; i < n; i ++){
	// 		if(ask(i) == vector<int>{0, 0}){
	// 			return i;
	// 		}
	// 	}
	// }
	int j = 0;
	int rig = 0;
	_q = 0;
	while(true){
		auto v = ask(j);
		_q ++;
		if(v[0] + v[1] == 0){
			return j;
		}
		if(n - v[0] + v[1] > n / 2){
			rig = v[1];
			break;
		}
		j ++;
		rig --;
	}
	// cout << 3 << ' ';
	// for(int i = 0; i < 400; i++){
	// 	cout << "2 ";
	// }
	// for(int i = 0; i < 199000; i ++){
	// 	cout << "3 ";
	// }
	// cout << "1 ";
	//cout << j << endl;
	while(true){
		int l = j, r = n;
		while(r - l > 1){
			int m = (l + r) / 2;
			_q ++;
			assert(_q <= 10000);
			vector<int> v = ask(m);
			if(v[0] + v[1] == 0){
				return m;
			}
			if(v[1] == rig){
				l = m;
			}else r = m;
		}
		//cout << r << ' ' << rig << endl;
		j = r + 1;
		rig --;
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...