# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1076211 | amin | The Big Prize (IOI17_prize) | C++14 | 46 ms | 2132 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>q;
int a[1000000],b[1000000];
int find_best(int n) {
int cur=0;
for(int i=0;i<n;i++)
{
a[i]=-1;
b[i]=-1;
}
q=ask(0);
a[0]=q[0];
b[0]=q[1];
int ma=max(ma,a[0]+b[0]);
while(cur!=n)
{
// cout<<cur<<endl;
if(a[cur]==-1)
{
q=ask(cur);
a[cur]=q[0];
b[cur]=q[1];
}
int p=a[cur];
int pp=b[cur];
if(p==0&&pp==0)
return cur;
if(p+pp<ma)
{
cur++;
continue;
}
ma=max(ma,p+pp);
int l=0;
int j=sqrt(n);
int r=min(n-cur,j);
while(l<r-1)
{
int mid=(l+r)/2;
if(a[cur+mid]==-1)
{
q=ask(cur+mid);
a[cur+mid]=q[0];
b[cur+mid]=q[1];
}
if(p==a[cur+mid]&&pp==b[cur+mid])
{
l=mid;
}else
r=mid;
}
cur=r+cur;
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |