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;
int find_best(int n) {
vector<vector<int> > a(n);
int maxi = 0;
for(int i = 0; i < n; i++){
if(a[i].empty()) a[i] = ask(i);
if(a[i][0] == 0 && a[i][1] == 0) return i;
if(a[i][0] + a[i][1] > maxi) maxi = a[i][0] + a[i][1];
if(a[i][0] + a[i][1] == maxi){
int ini = i, fim = n - 1;
while(ini != fim){
int mid = (ini + fim) >> 1;
if(ini == fim - 1) mid = fim;
if(a[mid].empty()) a[mid] = ask(mid);
if(a[mid][0] == 0 && a[mid][1] == 0) return mid;
if(a[mid][0] + a[mid][1] > maxi){
maxi = a[mid][0] + a[mid][1];
break;
}
if(a[mid][0] != a[i][0] || a[mid][1] != a[i][1]) fim = mid - 1;
else ini = mid;
}
i = ini;
}
}
return n - 1;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |