#include "prize.h"
#include<bits/stdc++.h>
using namespace std;
#define PB push_back
#define MP make_pair
#define P push
#define I insert
#define F first
#define S second
vector<pair<int,int> > v;
int sum[200000];
void query(int i){
vector<int> tv=ask(i);
v[i]={tv[0],tv[1]};
sum[i]=v[i].F+v[i].S;
return;
}
int find_best(int n) {
int lol=0;
for(int i=0;i<n;i++)v.PB(MP(-1,-1));
for(int i=0;i<500;i++){
query(i);
if(sum[i]==0)return i;
lol=max(lol,sum[i]);
}
for(int i=0;i<n;i++){
if(v[i].F==-1)query(i);
if(sum[i]==0)return i;
if(sum[i]!=lol)continue;
int l=i,r=n-1;
while(l<=r){
int m=(l+r)/2;
if(v[m].F==-1)query(m);
if(sum[m]==0)return m;
if(v[m]==v[i]){
l=m+1;
i=m;
}
else r=m-1;
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
2468 KB |
Output is correct |
2 |
Correct |
6 ms |
2464 KB |
Output is correct |
3 |
Correct |
6 ms |
2464 KB |
Output is correct |
4 |
Correct |
7 ms |
2372 KB |
Output is correct |
5 |
Correct |
6 ms |
2448 KB |
Output is correct |
6 |
Correct |
3 ms |
2468 KB |
Output is correct |
7 |
Correct |
9 ms |
2460 KB |
Output is correct |
8 |
Correct |
8 ms |
2464 KB |
Output is correct |
9 |
Correct |
4 ms |
2472 KB |
Output is correct |
10 |
Correct |
7 ms |
2500 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
2448 KB |
Output is correct |
2 |
Correct |
6 ms |
2456 KB |
Output is correct |
3 |
Correct |
7 ms |
2372 KB |
Output is correct |
4 |
Correct |
7 ms |
2464 KB |
Output is correct |
5 |
Correct |
7 ms |
2464 KB |
Output is correct |
6 |
Correct |
3 ms |
2460 KB |
Output is correct |
7 |
Correct |
7 ms |
2468 KB |
Output is correct |
8 |
Correct |
6 ms |
2460 KB |
Output is correct |
9 |
Correct |
4 ms |
2424 KB |
Output is correct |
10 |
Correct |
7 ms |
2500 KB |
Output is correct |
11 |
Correct |
11 ms |
2456 KB |
Output is correct |
12 |
Correct |
7 ms |
2364 KB |
Output is correct |
13 |
Correct |
12 ms |
2472 KB |
Output is correct |
14 |
Correct |
8 ms |
616 KB |
Output is correct |
15 |
Correct |
16 ms |
2464 KB |
Output is correct |
16 |
Partially correct |
31 ms |
2772 KB |
Partially correct - number of queries: 7218 |
17 |
Correct |
10 ms |
2460 KB |
Output is correct |
18 |
Partially correct |
65 ms |
2740 KB |
Partially correct - number of queries: 8374 |
19 |
Correct |
7 ms |
2460 KB |
Output is correct |
20 |
Correct |
23 ms |
1468 KB |
Output is correct |
21 |
Correct |
26 ms |
2524 KB |
Output is correct |
22 |
Correct |
14 ms |
2468 KB |
Output is correct |
23 |
Correct |
8 ms |
2468 KB |
Output is correct |
24 |
Correct |
8 ms |
2460 KB |
Output is correct |
25 |
Correct |
54 ms |
2508 KB |
Output is correct |
26 |
Correct |
50 ms |
2520 KB |
Output is correct |
27 |
Correct |
8 ms |
2460 KB |
Output is correct |
28 |
Partially correct |
65 ms |
2736 KB |
Partially correct - number of queries: 7902 |
29 |
Partially correct |
67 ms |
2712 KB |
Partially correct - number of queries: 6143 |
30 |
Partially correct |
67 ms |
2740 KB |
Partially correct - number of queries: 8307 |
31 |
Correct |
6 ms |
2500 KB |
Output is correct |
32 |
Correct |
12 ms |
2448 KB |
Output is correct |
33 |
Correct |
0 ms |
208 KB |
Output is correct |
34 |
Correct |
33 ms |
2460 KB |
Output is correct |
35 |
Correct |
5 ms |
2444 KB |
Output is correct |
36 |
Correct |
15 ms |
2448 KB |
Output is correct |
37 |
Correct |
9 ms |
2464 KB |
Output is correct |
38 |
Correct |
8 ms |
2444 KB |
Output is correct |
39 |
Correct |
29 ms |
2520 KB |
Output is correct |
40 |
Partially correct |
42 ms |
2756 KB |
Partially correct - number of queries: 7177 |
41 |
Partially correct |
54 ms |
2640 KB |
Partially correct - number of queries: 5238 |
42 |
Partially correct |
49 ms |
2608 KB |
Partially correct - number of queries: 5238 |
43 |
Correct |
39 ms |
2616 KB |
Output is correct |
44 |
Correct |
35 ms |
2496 KB |
Output is correct |
45 |
Correct |
27 ms |
2500 KB |
Output is correct |
46 |
Correct |
4 ms |
2460 KB |
Output is correct |
47 |
Correct |
18 ms |
2548 KB |
Output is correct |
48 |
Partially correct |
58 ms |
2712 KB |
Partially correct - number of queries: 6334 |
49 |
Correct |
11 ms |
2372 KB |
Output is correct |
50 |
Partially correct |
71 ms |
2740 KB |
Partially correct - number of queries: 8370 |
51 |
Correct |
21 ms |
2520 KB |
Output is correct |
52 |
Correct |
4 ms |
2460 KB |
Output is correct |
53 |
Correct |
8 ms |
2468 KB |
Output is correct |
54 |
Correct |
46 ms |
2584 KB |
Output is correct |
55 |
Correct |
6 ms |
2400 KB |
Output is correct |
56 |
Partially correct |
84 ms |
2716 KB |
Partially correct - number of queries: 8374 |
57 |
Partially correct |
43 ms |
2584 KB |
Partially correct - number of queries: 6236 |
58 |
Partially correct |
26 ms |
2660 KB |
Partially correct - number of queries: 6320 |
59 |
Partially correct |
47 ms |
2584 KB |
Partially correct - number of queries: 5235 |
60 |
Correct |
42 ms |
2684 KB |
Output is correct |
61 |
Correct |
8 ms |
2472 KB |
Output is correct |
62 |
Correct |
5 ms |
2464 KB |
Output is correct |
63 |
Correct |
8 ms |
2460 KB |
Output is correct |
64 |
Correct |
9 ms |
2464 KB |
Output is correct |
65 |
Correct |
6 ms |
2464 KB |
Output is correct |
66 |
Correct |
9 ms |
2464 KB |
Output is correct |
67 |
Correct |
6 ms |
2468 KB |
Output is correct |
68 |
Correct |
6 ms |
2456 KB |
Output is correct |
69 |
Correct |
16 ms |
2500 KB |
Output is correct |
70 |
Correct |
4 ms |
2448 KB |
Output is correct |
71 |
Partially correct |
68 ms |
2832 KB |
Partially correct - number of queries: 8270 |
72 |
Correct |
9 ms |
2624 KB |
Output is correct |
73 |
Partially correct |
82 ms |
2756 KB |
Partially correct - number of queries: 8159 |
74 |
Partially correct |
107 ms |
2800 KB |
Partially correct - number of queries: 8219 |
75 |
Correct |
7 ms |
2500 KB |
Output is correct |
76 |
Partially correct |
69 ms |
2648 KB |
Partially correct - number of queries: 7113 |
77 |
Partially correct |
67 ms |
2740 KB |
Partially correct - number of queries: 7051 |
78 |
Correct |
13 ms |
2520 KB |
Output is correct |
79 |
Correct |
42 ms |
2652 KB |
Output is correct |
80 |
Partially correct |
70 ms |
2760 KB |
Partially correct - number of queries: 8409 |
81 |
Partially correct |
87 ms |
2740 KB |
Partially correct - number of queries: 8420 |
82 |
Partially correct |
68 ms |
2768 KB |
Partially correct - number of queries: 8353 |
83 |
Correct |
6 ms |
2424 KB |
Output is correct |
84 |
Partially correct |
73 ms |
2648 KB |
Partially correct - number of queries: 6970 |
85 |
Partially correct |
78 ms |
2664 KB |
Partially correct - number of queries: 8433 |
86 |
Correct |
8 ms |
2500 KB |
Output is correct |
87 |
Correct |
7 ms |
2500 KB |
Output is correct |
88 |
Correct |
7 ms |
2500 KB |
Output is correct |
89 |
Correct |
7 ms |
2468 KB |
Output is correct |
90 |
Correct |
7 ms |
2500 KB |
Output is correct |
91 |
Correct |
7 ms |
2500 KB |
Output is correct |
92 |
Correct |
8 ms |
2500 KB |
Output is correct |
93 |
Correct |
13 ms |
2500 KB |
Output is correct |
94 |
Correct |
9 ms |
2500 KB |
Output is correct |
95 |
Correct |
14 ms |
2500 KB |
Output is correct |
96 |
Correct |
12 ms |
2472 KB |
Output is correct |
97 |
Correct |
7 ms |
2500 KB |
Output is correct |