#include "prize.h"
#include<bits/stdc++.h>
using namespace std;
int find_best(int n) {
int y = 0,l,r,m,x,big = 0,z,k;
for(int i = 0; (i+1)*(i+1) <= n; i++) {
vector<int> a = ask(i);
if(a[0] == 0 && a[1] == 0) {
return i;
}
if(a[0]+a[1] > big) {
big = a[0]+a[1];
y = i+1;
}
}
srand(time(NULL));
while(y < n) {
vector<int> a = ask(y);
x = a[0];
z = a[1];
l = y;
r = n-1;
k = rand()%200+250;
if(x+z == 0) {
return y;
}
for(int i = l+k; i < n; i+=k) {
a = ask(i);
if(a[0] == x && a[1] == z) {
l = i;
}
else {
r = i-1;
l = r-k+1;
break;
}
}
while(l < r) {
m = (l+r+1)/2;
a = ask(m);
if(a[0] == x && a[1] == z) {
l = m;
}
else {
r = m-1;
}
}
a = ask(l+1);
if(a[0] == 0 && a[1] == 0) {
return l+1;
}
y = l+2;
}
}
Compilation message
prize.cpp: In function 'int find_best(int)':
prize.cpp:55:1: warning: control reaches end of non-void function [-Wreturn-type]
55 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
208 KB |
Output is correct |
2 |
Correct |
6 ms |
292 KB |
Output is correct |
3 |
Correct |
6 ms |
292 KB |
Output is correct |
4 |
Correct |
9 ms |
296 KB |
Output is correct |
5 |
Correct |
4 ms |
296 KB |
Output is correct |
6 |
Correct |
1 ms |
284 KB |
Output is correct |
7 |
Correct |
3 ms |
288 KB |
Output is correct |
8 |
Correct |
6 ms |
292 KB |
Output is correct |
9 |
Correct |
6 ms |
292 KB |
Output is correct |
10 |
Correct |
4 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
292 KB |
Output is correct |
2 |
Correct |
3 ms |
292 KB |
Output is correct |
3 |
Correct |
6 ms |
208 KB |
Output is correct |
4 |
Correct |
7 ms |
292 KB |
Output is correct |
5 |
Correct |
5 ms |
208 KB |
Output is correct |
6 |
Correct |
0 ms |
292 KB |
Output is correct |
7 |
Correct |
6 ms |
208 KB |
Output is correct |
8 |
Correct |
4 ms |
208 KB |
Output is correct |
9 |
Correct |
6 ms |
288 KB |
Output is correct |
10 |
Correct |
9 ms |
208 KB |
Output is correct |
11 |
Correct |
5 ms |
288 KB |
Output is correct |
12 |
Correct |
4 ms |
208 KB |
Output is correct |
13 |
Correct |
5 ms |
296 KB |
Output is correct |
14 |
Correct |
4 ms |
208 KB |
Output is correct |
15 |
Correct |
11 ms |
208 KB |
Output is correct |
16 |
Partially correct |
39 ms |
208 KB |
Partially correct - number of queries: 5281 |
17 |
Correct |
3 ms |
292 KB |
Output is correct |
18 |
Partially correct |
34 ms |
292 KB |
Partially correct - number of queries: 6287 |
19 |
Correct |
2 ms |
292 KB |
Output is correct |
20 |
Correct |
15 ms |
336 KB |
Output is correct |
21 |
Correct |
22 ms |
208 KB |
Output is correct |
22 |
Correct |
3 ms |
288 KB |
Output is correct |
23 |
Correct |
4 ms |
208 KB |
Output is correct |
24 |
Correct |
2 ms |
336 KB |
Output is correct |
25 |
Correct |
18 ms |
208 KB |
Output is correct |
26 |
Correct |
27 ms |
292 KB |
Output is correct |
27 |
Correct |
6 ms |
208 KB |
Output is correct |
28 |
Partially correct |
20 ms |
288 KB |
Partially correct - number of queries: 5958 |
29 |
Correct |
37 ms |
296 KB |
Output is correct |
30 |
Partially correct |
49 ms |
208 KB |
Partially correct - number of queries: 6249 |
31 |
Correct |
4 ms |
208 KB |
Output is correct |
32 |
Correct |
12 ms |
296 KB |
Output is correct |
33 |
Correct |
0 ms |
208 KB |
Output is correct |
34 |
Correct |
7 ms |
292 KB |
Output is correct |
35 |
Correct |
4 ms |
288 KB |
Output is correct |
36 |
Correct |
13 ms |
292 KB |
Output is correct |
37 |
Correct |
5 ms |
272 KB |
Output is correct |
38 |
Correct |
2 ms |
208 KB |
Output is correct |
39 |
Correct |
10 ms |
288 KB |
Output is correct |
40 |
Partially correct |
33 ms |
208 KB |
Partially correct - number of queries: 5452 |
41 |
Correct |
13 ms |
288 KB |
Output is correct |
42 |
Correct |
32 ms |
208 KB |
Output is correct |
43 |
Correct |
11 ms |
328 KB |
Output is correct |
44 |
Correct |
22 ms |
292 KB |
Output is correct |
45 |
Correct |
8 ms |
288 KB |
Output is correct |
46 |
Correct |
3 ms |
208 KB |
Output is correct |
47 |
Correct |
26 ms |
288 KB |
Output is correct |
48 |
Correct |
31 ms |
208 KB |
Output is correct |
49 |
Correct |
5 ms |
292 KB |
Output is correct |
50 |
Partially correct |
23 ms |
296 KB |
Partially correct - number of queries: 6239 |
51 |
Correct |
18 ms |
288 KB |
Output is correct |
52 |
Correct |
3 ms |
292 KB |
Output is correct |
53 |
Correct |
4 ms |
296 KB |
Output is correct |
54 |
Correct |
10 ms |
292 KB |
Output is correct |
55 |
Correct |
2 ms |
328 KB |
Output is correct |
56 |
Partially correct |
21 ms |
284 KB |
Partially correct - number of queries: 6283 |
57 |
Correct |
15 ms |
292 KB |
Output is correct |
58 |
Correct |
39 ms |
208 KB |
Output is correct |
59 |
Correct |
30 ms |
292 KB |
Output is correct |
60 |
Correct |
29 ms |
288 KB |
Output is correct |
61 |
Correct |
6 ms |
296 KB |
Output is correct |
62 |
Correct |
2 ms |
296 KB |
Output is correct |
63 |
Correct |
9 ms |
208 KB |
Output is correct |
64 |
Correct |
7 ms |
288 KB |
Output is correct |
65 |
Correct |
3 ms |
292 KB |
Output is correct |
66 |
Correct |
8 ms |
208 KB |
Output is correct |
67 |
Correct |
4 ms |
328 KB |
Output is correct |
68 |
Correct |
3 ms |
208 KB |
Output is correct |
69 |
Correct |
5 ms |
208 KB |
Output is correct |
70 |
Correct |
4 ms |
292 KB |
Output is correct |
71 |
Partially correct |
47 ms |
208 KB |
Partially correct - number of queries: 6229 |
72 |
Correct |
9 ms |
208 KB |
Output is correct |
73 |
Partially correct |
50 ms |
208 KB |
Partially correct - number of queries: 6154 |
74 |
Partially correct |
39 ms |
208 KB |
Partially correct - number of queries: 6197 |
75 |
Correct |
9 ms |
208 KB |
Output is correct |
76 |
Partially correct |
39 ms |
208 KB |
Partially correct - number of queries: 5475 |
77 |
Partially correct |
51 ms |
208 KB |
Partially correct - number of queries: 6095 |
78 |
Correct |
13 ms |
208 KB |
Output is correct |
79 |
Correct |
27 ms |
208 KB |
Output is correct |
80 |
Partially correct |
43 ms |
208 KB |
Partially correct - number of queries: 6111 |
81 |
Partially correct |
51 ms |
208 KB |
Partially correct - number of queries: 6100 |
82 |
Partially correct |
34 ms |
208 KB |
Partially correct - number of queries: 6063 |
83 |
Correct |
8 ms |
208 KB |
Output is correct |
84 |
Partially correct |
33 ms |
208 KB |
Partially correct - number of queries: 5185 |
85 |
Partially correct |
48 ms |
208 KB |
Partially correct - number of queries: 6111 |
86 |
Correct |
5 ms |
336 KB |
Output is correct |
87 |
Correct |
7 ms |
208 KB |
Output is correct |
88 |
Correct |
8 ms |
208 KB |
Output is correct |
89 |
Correct |
8 ms |
208 KB |
Output is correct |
90 |
Correct |
9 ms |
208 KB |
Output is correct |
91 |
Correct |
6 ms |
208 KB |
Output is correct |
92 |
Correct |
9 ms |
208 KB |
Output is correct |
93 |
Correct |
8 ms |
208 KB |
Output is correct |
94 |
Correct |
10 ms |
208 KB |
Output is correct |
95 |
Correct |
11 ms |
208 KB |
Output is correct |
96 |
Correct |
8 ms |
208 KB |
Output is correct |
97 |
Correct |
5 ms |
208 KB |
Output is correct |