# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1013416 | NintsiChkhaidze | The Big Prize (IOI17_prize) | C++17 | 52 ms | 5952 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>
#define pb push_back
#include "prize.h"
using namespace std;
bool fix[200003];
int Q;
vector <int> dp[200003];
vector <int> askk(int x){
return ask(x);
}
int find_best(int n){
int block = 500,mx = -1,idx = -1;
vector <int> opt;
for (int i = 0; i < min(n,block); i++){
vector <int> vec = askk(i);
int sum = vec[0] + vec[1];
if (sum == 0) return i;
if (sum > mx){
mx = sum;
opt = vec;
idx = i;
}
}
for (int i = idx; i < n; i++){
vector <int> vec = askk(i);
if (vec[0] + vec[1] == 0) {
return i;
}
if (vec[0] + vec[1] != mx) {
fix[i] = 1;
continue;
}
opt = vec;
int id = i;
int l = i, r = n - 1,res = i;
while (l <= r){
int mid = (l + r)/2;
vector <int> vec = askk(mid);
if (vec[0] + vec[1] == 0) {
return mid;
}
if (vec != opt){
r = mid - 1;
}else{
res = mid;
l = mid + 1;
}
}
for (int j = id; j <= res; j++)
fix[j] = 1;
i = res;
}
for (int i = 0; i < n; i++){
if (!fix[i]){
vector <int> vec = askk(i);
if (vec[0] + vec[1] == 0) {
return i;
}
}
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |