# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
100711 | Bodo171 | The Big Prize (IOI17_prize) | C++14 | 101 ms | 6176 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 <fstream>
#include <vector>
#include <iostream>
using namespace std;
const int nmax=200005;
const int prdf=500;//modifici dupa asta
int lg[nmax];
int spec[nmax];
int mx,nr,i;
vector<int> v[nmax];
int cate_st(int poz)
{
if(v[poz].empty()) v[poz]=ask(poz);
return v[poz][0];
}
int cate(int poz)
{
if(v[poz].empty()) v[poz]=ask(poz);
return (v[poz][0]+v[poz][1]);
}
void solve(int st,int dr)
{
int len=spec[dr]-spec[st];
int poz=spec[st];
for(int p=lg[len];p>=0;p--)
{
if(poz+(1<<p)<spec[dr])
{
if(cate_st(poz+(1<<p))==st&&cate(poz+(1<<p))==mx)
poz+=(1<<p);
}
}
poz++;spec[st+1]=poz;
}
int find_best(int n) {
for(i=2;i<=n+1;i++)
lg[i]=lg[i/2]+1;
for(i=0;i<min(prdf,n);i++)
{
v[i]=ask(i);
if(v[i][0]+v[i][1]>mx)
mx=v[i][0]+v[i][1];
}
spec[0]=-1;
for(i=0;i<min(prdf,n);i++)
{
if(v[i][0]+v[i][1]!=mx)
spec[++nr]=i;
}
spec[mx+1]=n;
for(int i=nr;i<mx;i++)
{
solve(i,mx+1);
}
for(i=1;i<=mx;i++)
if(cate(spec[i])==0)
return spec[i];
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |