# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
425430 | jk410 | The Big Prize (IOI17_prize) | C++17 | 165 ms | 5328 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 <bits/stdc++.h>
#include "prize.h"
using namespace std;
typedef vector<int> vi;
int N,RT,Sum,Ans=-1;
vi ask_res[200000];
vi ask_query(int i){
vi &r=ask_res[i];
if (r.size())
return r;
return r=ask(i);
}
void find_not_candy(int s,int e){
if (s>e)
return;
vi q=ask_query(e);
if (q[0]+q[1]>N/2&&Sum==q[0])
return;
int l=s,r=e,t;
while (l<=r){
int m=(l+r)>>1;
q=ask_query(m);
if (q[0]+q[1]>N/2){
if (Sum<q[0])
r=m-1;
else
l=m+1;
}
else{
t=m;
r=m-1;
}
}
q=ask_query(t);
if (!q[0]&&!q[1]){
Ans=t;
return;
}
Sum++;
find_not_candy(t+1,e);
}
int find_best(int n) {
N=n;
RT=sqrt(N);
for (int i=0; i<N; i+=RT){
find_not_candy(i,i+RT-1);
if (Ans!=-1)
return Ans;
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |