# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
135857 | alexandra_udristoiu | The Big Prize (IOI17_prize) | C++14 | 83 ms | 548 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<iostream>
#include<vector>
#include<cmath>
#include "prize.h"
using namespace std;
int find_best(int n){
int nr, p, st, dr, mid, r, i, x;
vector<int> a;
r = sqrt(n * 1.0);
x = 0;
for(i = 0; i <= r; i++){
a = ask(i);
if(a[0] == 0 && a[1] == 0){
return i;
}
if(x <= a[1] + a[0]){
x = a[1] + a[0];
p = i;
nr = a[1];
}
}
while(nr > 0){
st = p + 1;
dr = n;
while(st <= dr){
mid = (st + dr) / 2;
a = ask(mid);
if(a[1] == nr){
st = mid + 1;
}
else{
dr = mid - 1;
}
}
a = ask(st);
if(a[1] == 0){
return st;
}
p = st + 1;
nr--;
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |