#include <bits/stdc++.h>
#include "prize.h"
using namespace std;
int find_best(int n) {
int N=2e5+5;
int lo=(int)sqrt(N);
int maxx=0;
for(int i=0;i<lo;i++)
{
vector<int> tr=ask(i);
int t=tr[0]+tr[1];
if(t==0)
return i;
maxx=max(maxx,t);
}
int nasao=0;
int last=0;
while(true)
{
int l=last,r=n-1;
while(l<r)
{
int m=(l+r)>>1;
vector<int> tr=ask(m);
int t=tr[0]+tr[1];
if(t==0)
return m;
if(t!=maxx)
{
r=m;
continue;
}
if(tr[0]>nasao)
r=m-1;
else
l=m+1;
}
vector<int> tr=ask(l);
int t=tr[0]+tr[1];
if(t==0)
return l;
last=l+1;
nasao++;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
248 KB |
Output is correct |
2 |
Correct |
4 ms |
452 KB |
Output is correct |
3 |
Correct |
6 ms |
528 KB |
Output is correct |
4 |
Correct |
4 ms |
576 KB |
Output is correct |
5 |
Correct |
6 ms |
576 KB |
Output is correct |
6 |
Correct |
2 ms |
576 KB |
Output is correct |
7 |
Correct |
5 ms |
576 KB |
Output is correct |
8 |
Correct |
4 ms |
576 KB |
Output is correct |
9 |
Correct |
6 ms |
576 KB |
Output is correct |
10 |
Correct |
7 ms |
576 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
576 KB |
Output is correct |
2 |
Correct |
4 ms |
576 KB |
Output is correct |
3 |
Correct |
6 ms |
576 KB |
Output is correct |
4 |
Correct |
4 ms |
576 KB |
Output is correct |
5 |
Correct |
7 ms |
576 KB |
Output is correct |
6 |
Correct |
2 ms |
576 KB |
Output is correct |
7 |
Correct |
6 ms |
576 KB |
Output is correct |
8 |
Correct |
6 ms |
576 KB |
Output is correct |
9 |
Correct |
4 ms |
576 KB |
Output is correct |
10 |
Correct |
5 ms |
576 KB |
Output is correct |
11 |
Correct |
5 ms |
576 KB |
Output is correct |
12 |
Correct |
7 ms |
576 KB |
Output is correct |
13 |
Correct |
6 ms |
576 KB |
Output is correct |
14 |
Correct |
11 ms |
576 KB |
Output is correct |
15 |
Correct |
16 ms |
580 KB |
Output is correct |
16 |
Partially correct |
78 ms |
580 KB |
Partially correct - number of queries: 7144 |
17 |
Correct |
4 ms |
588 KB |
Output is correct |
18 |
Partially correct |
75 ms |
588 KB |
Partially correct - number of queries: 8295 |
19 |
Correct |
8 ms |
588 KB |
Output is correct |
20 |
Correct |
30 ms |
588 KB |
Output is correct |
21 |
Correct |
43 ms |
588 KB |
Output is correct |
22 |
Correct |
6 ms |
588 KB |
Output is correct |
23 |
Correct |
4 ms |
592 KB |
Output is correct |
24 |
Correct |
8 ms |
592 KB |
Output is correct |
25 |
Correct |
24 ms |
592 KB |
Output is correct |
26 |
Correct |
45 ms |
592 KB |
Output is correct |
27 |
Correct |
7 ms |
592 KB |
Output is correct |
28 |
Partially correct |
34 ms |
592 KB |
Partially correct - number of queries: 7932 |
29 |
Partially correct |
28 ms |
592 KB |
Partially correct - number of queries: 6133 |
30 |
Partially correct |
76 ms |
592 KB |
Partially correct - number of queries: 8226 |
31 |
Correct |
4 ms |
592 KB |
Output is correct |
32 |
Correct |
8 ms |
592 KB |
Output is correct |
33 |
Correct |
2 ms |
592 KB |
Output is correct |
34 |
Correct |
28 ms |
592 KB |
Output is correct |
35 |
Correct |
7 ms |
592 KB |
Output is correct |
36 |
Correct |
26 ms |
592 KB |
Output is correct |
37 |
Correct |
8 ms |
592 KB |
Output is correct |
38 |
Correct |
4 ms |
592 KB |
Output is correct |
39 |
Correct |
42 ms |
592 KB |
Output is correct |
40 |
Partially correct |
73 ms |
592 KB |
Partially correct - number of queries: 7091 |
41 |
Partially correct |
50 ms |
592 KB |
Partially correct - number of queries: 5163 |
42 |
Partially correct |
52 ms |
592 KB |
Partially correct - number of queries: 5163 |
43 |
Correct |
44 ms |
592 KB |
Output is correct |
44 |
Correct |
27 ms |
592 KB |
Output is correct |
45 |
Correct |
35 ms |
592 KB |
Output is correct |
46 |
Correct |
4 ms |
716 KB |
Output is correct |
47 |
Correct |
40 ms |
716 KB |
Output is correct |
48 |
Partially correct |
72 ms |
716 KB |
Partially correct - number of queries: 6270 |
49 |
Correct |
6 ms |
716 KB |
Output is correct |
50 |
Partially correct |
74 ms |
716 KB |
Partially correct - number of queries: 8292 |
51 |
Correct |
30 ms |
716 KB |
Output is correct |
52 |
Correct |
4 ms |
716 KB |
Output is correct |
53 |
Correct |
10 ms |
716 KB |
Output is correct |
54 |
Correct |
37 ms |
716 KB |
Output is correct |
55 |
Correct |
6 ms |
716 KB |
Output is correct |
56 |
Partially correct |
72 ms |
716 KB |
Partially correct - number of queries: 8290 |
57 |
Partially correct |
27 ms |
716 KB |
Partially correct - number of queries: 6183 |
58 |
Partially correct |
53 ms |
716 KB |
Partially correct - number of queries: 6295 |
59 |
Partially correct |
54 ms |
716 KB |
Partially correct - number of queries: 5164 |
60 |
Correct |
58 ms |
716 KB |
Output is correct |
61 |
Correct |
10 ms |
716 KB |
Output is correct |
62 |
Correct |
4 ms |
716 KB |
Output is correct |
63 |
Correct |
4 ms |
716 KB |
Output is correct |
64 |
Correct |
7 ms |
716 KB |
Output is correct |
65 |
Correct |
6 ms |
716 KB |
Output is correct |
66 |
Correct |
21 ms |
716 KB |
Output is correct |
67 |
Correct |
7 ms |
716 KB |
Output is correct |
68 |
Correct |
6 ms |
716 KB |
Output is correct |
69 |
Correct |
20 ms |
716 KB |
Output is correct |
70 |
Correct |
6 ms |
716 KB |
Output is correct |
71 |
Partially correct |
78 ms |
716 KB |
Partially correct - number of queries: 8248 |
72 |
Correct |
11 ms |
716 KB |
Output is correct |
73 |
Partially correct |
43 ms |
716 KB |
Partially correct - number of queries: 8131 |
74 |
Partially correct |
78 ms |
716 KB |
Partially correct - number of queries: 8203 |
75 |
Correct |
8 ms |
716 KB |
Output is correct |
76 |
Partially correct |
66 ms |
716 KB |
Partially correct - number of queries: 7082 |
77 |
Partially correct |
58 ms |
716 KB |
Partially correct - number of queries: 8321 |
78 |
Correct |
12 ms |
716 KB |
Output is correct |
79 |
Correct |
42 ms |
716 KB |
Output is correct |
80 |
Partially correct |
37 ms |
716 KB |
Partially correct - number of queries: 8319 |
81 |
Partially correct |
70 ms |
716 KB |
Partially correct - number of queries: 8317 |
82 |
Partially correct |
84 ms |
716 KB |
Partially correct - number of queries: 8269 |
83 |
Correct |
9 ms |
716 KB |
Output is correct |
84 |
Partially correct |
50 ms |
716 KB |
Partially correct - number of queries: 6881 |
85 |
Partially correct |
39 ms |
716 KB |
Partially correct - number of queries: 8328 |
86 |
Incorrect |
92 ms |
716 KB |
Incorrect |
87 |
Halted |
0 ms |
0 KB |
- |