#include <bits/stdc++.h>
#include "prize.h"
#define maxN 200002
using namespace std;
int i,x=0;
vector <int> v,a[maxN];
vector <int> u,p;
int find_best(int n){
for(i=0;i<n && i<500;i++){
if(a[i].empty()) a[i]=ask(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;
}
if(n>1000){
for(i=0;i<1000;i++){
if(a[i*(n/1000)].empty()) a[i*(n/1000)]=ask(i*(n/1000));
if(a[i*(n/1000)][0]+a[i*(n/1000)][1]==x) {u.push_back(a[i*(n/1000)][0]); p.push_back(i*(n/1000));}
}
}
u.push_back(n);
p.push_back(n);
int p=-1;
for(int i=0;i<x;i++){
int l,d,m,tmp;
tmp=lower_bound(u.begin(),u.end(),v.size()+1)-u.begin();
l=p+1; d=p[tmp].second;
while(l<d){
m=(l+d)/2;
if(a[m].empty()) a[m]=ask(m);
if(a[m][0]+a[m][1]==x){
if(a[m][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++){
if(a[v[i]].empty()) a[v[i]]=ask(v[i]);
if(a[v[i]][0]+a[v[i]][1]==0) return v[i];
}
}
Compilation message
prize.cpp: In function 'int find_best(int)':
prize.cpp:29:17: error: invalid types 'int[int]' for array subscript
l=p+1; d=p[tmp].second;
^
prize.cpp:44:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(i=0;i<v.size();i++){
~^~~~~~~~~
prize.cpp:48:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^