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>
#include "prize.h"
using namespace std;
const int MAX_VAL=200*1000+5;
int nbVal,nbPasMax,rep=-1;
set<int> memeSom[MAX_VAL];
vector<int> ans[MAX_VAL];
void calc(int deb,int fin) {
if (fin<deb or rep!=-1) {
return;
}
int mid=(deb+fin)/2;
ans[mid]=ask(mid);
int som=ans[mid][0]+ans[mid][1];
if (som==0) {
rep=mid;
}
memeSom[som].insert(mid);
auto it=memeSom[som].upper_bound(mid);
if ((*it)==MAX_VAL or ans[mid][0]!=ans[(*it)][0]) {
calc(mid+1,fin);
}
it=memeSom[som].lower_bound(mid);
it--;
if ((*it)==-MAX_VAL or ans[mid][0]!=ans[(*it)][0]) {
calc(deb,mid-1);
}
}
int find_best(int n) {
nbVal=n;
for (int i=0;i<nbVal;i++) {
memeSom[i].insert(MAX_VAL);
memeSom[i].insert(-MAX_VAL);
}
calc(0,nbVal-1);
return rep;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |