# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1060906 | onbert | The Big Prize (IOI17_prize) | C++17 | 63 ms | 11604 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;
const int maxn = 2e5;
vector<int> vals[maxn];
vector<int> qry(int i) {
if (vals[i][0]!=-1) return vals[i];
else return vals[i] = ask(i);
}
int find_best(int n) {
for (int i=0;i<n;i++) vals[i] = {-1, -1};
int mx = 0;
for (int i=0;i<n;i++) {
vector<int> x = qry(i);
mx = max(x[0]+x[1], mx);
if (x[0] + x[1] == 0) return i;
int l = i, r = n-1;
while (l<r && x[0]+x[1] == mx) {
int mid = (l+r+1)/2;
vector<int> y = qry(mid);
mx = max(y[0]+y[1], mx);
if (y[0]+y[1]==0) return mid;
if (y[0]!=x[0] || y[1]!=x[1]) r = mid-1;
else l = mid;
}
i = l;
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |