Submission #423081

#TimeUsernameProblemLanguageResultExecution timeMemory
423081albertolg101The Big Prize (IOI17_prize)C++17
20 / 100
112 ms320 KiB
#include <bits/stdc++.h>
#include "prize.h"

using namespace std; 

int find_best(int n) {

	vector<int> ar = ask(0);
	int sum = ar[1];

	if(ar[1] == 0)
		return 0;

	int pos = 0;

	//cout << sum << endl ;

	while(true)
	{
		//cout << pos << ' ' << ar[1] << endl ;

		for(int i = 17 ; i >= 0 ; i--)
		{
			int target = pos + (1<<i);

			if(target < n)
			{
				vector<int> temp = ask(target);
				//cout << target << ' ' << temp[0] << ' ' << temp[1] << endl ;
				if(temp[0] + temp[1] == sum and temp[1] == ar[1])
					pos = target;
			}
		}

		pos++;
		ar = ask(pos);
		
		while(true)
		{
			ar = ask(pos);

			if(ar[0] + ar[1] == 0)
				return pos;

			else if(ar[0] + ar[1] == sum)
				break;
		
			pos++;
		}
	} 
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...