#include <bits/stdc++.h>
//#include "grader.cpp"
#include "prize.h"
using namespace std;
#define mp make_pair
#define pb push_back
const int INF = 1000000000;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef long double num;
typedef pair<num, num> nn;
typedef vector<nn> vnn;
typedef vector<num> vn;
typedef vector<vn> vvn;
vii answers;
int maxVal = 0;
int N;
ii query(int i){
if(answers[i] != mp(-1, -1)) return answers[i];
vi a = ask(i);
return answers[i] = mp(a[0], a[1]);
}
void genQueries(){
// do 711 queries in the shape of a bs
queue<ii> bounds;
bounds.push(mp(-1, N));
int queriesLeft = 711;
while(queriesLeft --){
ii q = bounds.front(); bounds.pop();
int mb = (q.first+q.second)/2;
query(mb);
maxVal = max(maxVal, answers[mb].first + answers[mb].second);
bounds.push(mp(q.first, mb));
bounds.push(mp(mb, q.second));
}
}
int find_best(int n){
N = n;
int betterFound = 0;
int lb = -1;
while(betterFound < maxVal){
int rb = n;
while(lb + 1 != rb){
int mb = (lb + rb)/2;
ii ans = query(mb);
if(ans.second < maxVal - betterFound){
rb = mb;
} else {
lb = mb;
}
}
betterFound++;
lb++;
}
for(int i = 0; i < answers.size(); i++){
if(answers[i] == mp(0, 0)) return i;
}
}
Compilation message
prize.cpp: In function 'int find_best(int)':
prize.cpp:66:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0; i < answers.size(); i++){
~~^~~~~~~~~~~~~~~~
prize.cpp:70:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
answer is not correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
answer is not correct |
2 |
Halted |
0 ms |
0 KB |
- |