# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
410086 | dreezy | The Big Prize (IOI17_prize) | C++17 | 89 ms | 336 KiB |
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 "prize.h"
#include <bits/stdc++.h>
using namespace std;
/*********************************************************************************************************************/
int find_best(int n) {
int curtotal = -1;
for(int i =0; i<10; i++){
vector<int> res= ask(n/10 *i);
if( !res[0] && !res[1]) return n/10 *i;
curtotal = max(curtotal,res[0] +res[1]);
}
int left = 0, right = n-1;
int target =1;
vector<bool> vis(n);
int cnt =0;
while(true){
int ind = (left +right) /2 ;
//cout << left <<", "<<ind<<", "<<right<<": "<<target<<" "<<curtotal<<endl;
vector<int> res = ask(ind);
if(res[0] + res[1] == 0)
return ind;
if(res[0] + res[1] < curtotal){
int numvis = 1;
res = ask(--ind);
while(res[0]+ res[1] < curtotal){
if(res[0] + res[1] == 0)
return ind;
numvis++;
--ind;
//cout <<ind<<":"<<endl;
if(ind <0){
target += numvis;
break;
}
if(vis[ind])
{
target+= numvis;
break;
}
res = ask(ind);
}
if(res[0] + res[1] == curtotal){
target = res[0]+ numvis +1;
left = ind +1;
right = n-1;
}
}
if(res[0] < target){
left = ind +1;
}
else{
right = ind - 1;
}
//cnt++;
//if(cnt >=20) break;
}
return 0;
}
/*********************************************************************************************************************/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |