# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
288371 | davi_bart | The Big Prize (IOI17_prize) | C++14 | 109 ms | 512 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;
#define ll long long
#define fi first
#define se second
#define ld long double
vector<int> ask(int i);
int solve(int n){
for(int i=0;i<n;i++){
auto res=ask(i);
if(res[0]+res[1]==0)return i;
}
}
int find_best(int n){
if(n<=5000)return solve(n);
int ma=0;
for(int i=0;i<500;i++){
auto res=ask(i);
ma=max(ma,res[0]+res[1]);
if(res[0]+res[1]==0)return i;
}
int presi=0;
int pos=-1;
while(1){
int q=20;
while(q>=0){
if((1<<q)+pos>=n){
q--;
continue;
}
auto res=ask(pos+(1<<q));
if(res[0]==presi && res[0]+res[1]==ma)pos+=(1<<q);
q--;
}
while(1){
auto res=ask(pos+1);
if(res[0]==0 && res[1]==0)return pos+1;
pos++;
if(res[0]+res[1]==ma)break;
presi++;
}
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |