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;
#define ll int
#define endl "\n"
#define sz(x) (ll)x.size()
#define F first
#define S second
#define pb push_back
typedef vector <ll> vi;
typedef pair <ll,ll> ii;
typedef vector <ii> vii;
#define dbg(x) cout<<#x<<": "<<x<<endl;
#define dbg2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl;
#define dbg3(x,y,z) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<" "<<#z<<": "<<z<<endl;
void printVct(vi &v){
for (ll i =0; i<sz(v); i++){
cout<<v[i]<<" ";
}
cout<<endl;
}
int find_best(int n) {
// for(int i = 0; i < n; i++) {
// std::vector<int> res = ask(i);
// if(res[0] + res[1] == 0)
// return i;
// }
ll l = 0, r = n-1, mid;
while (l <= r){
mid = (l+r) / 2;
vi v = ask(mid);
if (v[0] == 0 && v[1] == 0){
return mid;
}
else if (v[0] == 1){ //go left
r = mid-1;
}
else{
l = mid+1;
}
}
return -1;
}
/*
6
1 2 2 2 2 2
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |