#include "prize.h"
#include <bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int ans[N][2],S=34;
int find_best(int n) {
int s=0,mx=0;
for (int i=0;i<min(500,n);i++){
vector<int> v=ask(i);
ans[i][0]=v[0];
ans[i][1]=v[1];
if (v[0]+v[1]==0) return i;
if (v[0]+v[1]>mx){
mx=v[0]+v[1];
s=i;
}
}
//cout<<s<<endl;
for (int i=s;i+S<n;i+=S){
vector<int> v=ask(i+S);
ans[i+S][0]=v[0];
ans[i+S][1]=v[1];
if (v[0]+v[1]==0) return i+S;
if (v[0]==ans[i][0] && v[1]==ans[i][1]) continue;
for (int j=i+1;j<i+S;j++){
v=ask(j);
ans[j][0]=v[0];
ans[j][1]=v[1];
if (v[0]+v[1]==0) return j;
}
}
for (int i=max(0,n-S);i<n;i++){
vector<int> v=ask(i);
ans[i][0]=v[0];
ans[i][1]=v[1];
if (v[0]+v[1]==0) return i;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
596 KB |
Output is correct |
2 |
Correct |
21 ms |
1360 KB |
Output is correct |
3 |
Correct |
24 ms |
1120 KB |
Output is correct |
4 |
Correct |
31 ms |
1884 KB |
Output is correct |
5 |
Correct |
14 ms |
1072 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
15 ms |
1068 KB |
Output is correct |
8 |
Correct |
14 ms |
1256 KB |
Output is correct |
9 |
Correct |
17 ms |
1104 KB |
Output is correct |
10 |
Correct |
38 ms |
1872 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
596 KB |
Output is correct |
2 |
Correct |
15 ms |
1360 KB |
Output is correct |
3 |
Correct |
14 ms |
1104 KB |
Output is correct |
4 |
Partially correct |
51 ms |
2180 KB |
Partially correct - number of queries: 6416 |
5 |
Correct |
14 ms |
1112 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
23 ms |
1188 KB |
Output is correct |
8 |
Correct |
16 ms |
1184 KB |
Output is correct |
9 |
Correct |
15 ms |
956 KB |
Output is correct |
10 |
Partially correct |
28 ms |
2088 KB |
Partially correct - number of queries: 6415 |
11 |
Correct |
16 ms |
856 KB |
Output is correct |
12 |
Correct |
4 ms |
344 KB |
Output is correct |
13 |
Partially correct |
36 ms |
1988 KB |
Partially correct - number of queries: 7343 |
14 |
Correct |
5 ms |
344 KB |
Output is correct |
15 |
Correct |
10 ms |
592 KB |
Output is correct |
16 |
Incorrect |
39 ms |
920 KB |
Incorrect |
17 |
Halted |
0 ms |
0 KB |
- |