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;
typedef int ll;
ll id,l,r,m,x,mx;
vector<ll>v[200009];
int find_best(int n)
{
while(id<n)
{
if(v[id].empty())
v[id]=ask(id);
if(v[id][0]+v[id][1]==0)
return id;
mx=max(mx,v[id][0]+v[id][1]);
if(mx>v[id][0]+v[id][1])
{
id++;
continue;
}
x=min(n-1,id+488);
if(v[x].empty())
v[x]=ask(x);
if(v[x][0]+v[x][1]==0)
return x;
mx=max(mx,v[x][0]+v[x][1]);
if(v[x]==v[id])
{
id=x+1;
continue;
}
l=id,r=x+1;
while(r-l>1)
{
m=(l+r)/2;
if(v[m].empty())
v[m]=ask(m);
if(v[m][0]+v[m][1]==0)
return m;
mx=max(mx,v[m][0]+v[m][1]);
if(v[m]==v[id])
l=m;
else
r=m;
}
id=l+1;
}
}
Compilation message (stderr)
prize.cpp: In function 'int find_best(int)':
prize.cpp:48:1: warning: control reaches end of non-void function [-Wreturn-type]
48 | }
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |