# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
317370 | tigicha | The Big Prize (IOI17_prize) | C++14 | 0 ms | 0 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;
vector <int> v;
int mx, k, p, l, r, m, ans;
int find_best(int n){
for(int i=0; i<474;i++){
v=ask(i);
if(v[0]+v[1]==0) return i;
if(v[0]+v[1]>mx){
mx=v[0]+v[1];
k=i;
p=v[0];
}
}
while(true){
l=k+1;
r=n-1;
while(l<=r){
m=(l+r)/2;
v=ask(m);
if(v[0]+v[1]==0) return m;
if(v[0]+v[1]==mx && v[0]==p) l=m+1;
else r=m-1;
if(v[0]+v[1]!=mx) ans=m;
}
for(int i=ans; i<n; i++){
a=ask(i);
if(v[0]+v[1]==0) return i;
if(v[0]+v[1]==mx){
k=i;
p=a.first;
break;
}
}
}
}