This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |