# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
814697 | Dan4Life | The Big Prize (IOI17_prize) | C++17 | 78 ms | 936 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 pb push_back
const int mxN = (int)2e5+100;
int fen[mxN];
void upd(int x, int v){for(++x; x<mxN; x+=x&-x)fen[x]+=v;}
int sum(int x){int s=0;for(++x; x>0; x-=x&-x)s+=fen[x];return s;}
int find_best(int n) {
int pr = 0;
for(int _ = 0; _ < 500; _++){
int l = pr, r = n-1;
while(l<r){
int mid = (l+r)/2;
auto a = ask(mid);
if(a[0]+a[1]==0) return mid;
if(a[0]-sum(mid-1))r=mid-1;
else l=mid+1;
}
auto a = ask(l); pr = l+1;
if(a[0]+a[1]==0) return l;
if(a[0]!=sum(l)) upd(l,1);
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |