#include "prize.h"
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define ar array
#define pb push_back
#define ln '\n'
//#define int long long
using i64 = long long;
template <class F, class _S>
bool chmin(F &u, const _S &v){
bool flag = false;
if ( u > v ){
u = v; flag |= true;
}
return flag;
}
template <class F, class _S>
bool chmax(F &u, const _S &v){
bool flag = false;
if ( u < v ){
u = v; flag |= true;
}
return flag;
}
int find_best(int n){
vector <vector<int>> dp(n);
auto f = [&](int j){
if ( dp[j].empty() ){
dp[j] = ask(j);
}
return dp[j];
};
int ans = -1, cnt = 0;
for ( int i = n - 1; i >= 0; i-- ){
auto c = f(i);
if ( c[0] + c[1] == 0 ){
ans = i;
}
int s = c[0] + c[1];
int l = c[0], r = i;
while ( l < r ){
int m = (l + r) / 2;
if ( f(m) != c ){
l = m + 1;
} else r = m;
}
i = l; cnt++;
}
return ans;
}
Compilation message
prize.cpp: In function 'int find_best(int)':
prize.cpp:53:7: warning: unused variable 's' [-Wunused-variable]
53 | int s = c[0] + c[1];
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4952 KB |
Output is correct |
2 |
Correct |
2 ms |
4952 KB |
Output is correct |
3 |
Correct |
2 ms |
4952 KB |
Output is correct |
4 |
Correct |
2 ms |
4952 KB |
Output is correct |
5 |
Correct |
2 ms |
5032 KB |
Output is correct |
6 |
Correct |
2 ms |
4952 KB |
Output is correct |
7 |
Correct |
2 ms |
4952 KB |
Output is correct |
8 |
Correct |
2 ms |
4952 KB |
Output is correct |
9 |
Correct |
2 ms |
4952 KB |
Output is correct |
10 |
Correct |
2 ms |
4952 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4952 KB |
Output is correct |
2 |
Correct |
2 ms |
4952 KB |
Output is correct |
3 |
Correct |
2 ms |
4952 KB |
Output is correct |
4 |
Correct |
2 ms |
4952 KB |
Output is correct |
5 |
Correct |
2 ms |
4952 KB |
Output is correct |
6 |
Correct |
2 ms |
4952 KB |
Output is correct |
7 |
Correct |
2 ms |
4952 KB |
Output is correct |
8 |
Correct |
3 ms |
4952 KB |
Output is correct |
9 |
Correct |
2 ms |
4952 KB |
Output is correct |
10 |
Correct |
2 ms |
4952 KB |
Output is correct |
11 |
Correct |
9 ms |
5144 KB |
Output is correct |
12 |
Correct |
7 ms |
4952 KB |
Output is correct |
13 |
Correct |
6 ms |
5208 KB |
Output is correct |
14 |
Correct |
13 ms |
1112 KB |
Output is correct |
15 |
Incorrect |
27 ms |
5192 KB |
Incorrect |
16 |
Halted |
0 ms |
0 KB |
- |