# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
39896 | igzi | The Big Prize (IOI17_prize) | C++14 | 0 ms | 6900 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 <bits/stdc++.h>
#include "prize.h"
#define maxN 200002
using namespace std;
int i,x=0;
vector <int> v,a[maxN];
bool b[maxN];
/*vector <int> ask(int n){
cout<<n<<endl;
int x,y;
vector <int> a;
cin>>x>>y;
a.push_back(x);
a.push_back(y);
return a;
}*/
vector <int> get(int x){
if(b[x]) return a[x];
b[x]=true;
return ask(x);
}
int find_best(int n){
for(i=0;i<n;i++){
b[i]=false;
}
for(i=0;i<n && i<480;i++){
a[i]=get(i);
if(a[i][0]+a[i][1]>x) x=a[i][0]+a[i][1];
if(a[i][0]+a[i][1]==0) return i;
}
int p=0;
for(int i=0;i<x;i++){
int l,d,m;
l=p; d=n-1;
while(l!=d){
m=(l+d)/2;
a[m]=get(m);
if(a[i][0]+a[i][1]==x){
if(a[i][0]-v.size()>0) d=m-1;
else l=m+1;
}
else{
d=m;
}
}
v.push_back(l);
p=l;
}
for(i=0;i<v.size();i++){
a[v[i]]=get(v[i]);
if(a[v[i]][0]+a[v[i]][1]==0) return v[i];
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |