#include "prize.h"
#include<bits/stdc++.h>
using namespace std;
mt19937 rng(time(0));
int find_best(int n){
int ct=50,V=n;
while(ct--){
int x=rng()%n;
vector<int>tmp=ask(x);
if(n-(tmp[0]+tmp[1])<V) V=n-(tmp[0]+tmp[1]);
}
int res=-1;
set<int>st;
st.insert(-1),st.insert(n);
auto it=st.begin();
int sajz=0;
while(it!=st.end()){
auto it2=it;
int i=*it;
if(res!=-1 && res==i) break;
it++;
if(it==st.end()) break;
int j=*it;
int l=i+1,r=j-1;
while(l<=r){
int mid=(l+r)/2;
vector<int>tmp=ask(mid);
if(n-tmp[0]-tmp[1]!=V){
if(tmp[0]==0 && tmp[1]==0) res=mid;
st.insert(mid);
r=mid-1;
continue;
}
if(tmp[0]>=1+sajz) r=mid-1;
else l=mid+1;
}
it=it2;
it++;
sajz++;
}
/*for(int i = 0; i < n; i++) {
std::vector<int> res = ask(i);
if(res[0] + res[1] == 0)
return i;
}*/
return res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
600 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
596 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
432 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
596 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
2 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
2 ms |
600 KB |
Output is correct |
14 |
Correct |
2 ms |
344 KB |
Output is correct |
15 |
Correct |
5 ms |
440 KB |
Output is correct |
16 |
Partially correct |
34 ms |
676 KB |
Partially correct - number of queries: 6591 |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Partially correct |
37 ms |
692 KB |
Partially correct - number of queries: 7719 |
19 |
Correct |
1 ms |
344 KB |
Output is correct |
20 |
Correct |
13 ms |
436 KB |
Output is correct |
21 |
Correct |
10 ms |
692 KB |
Output is correct |
22 |
Correct |
3 ms |
344 KB |
Output is correct |
23 |
Correct |
1 ms |
436 KB |
Output is correct |
24 |
Correct |
1 ms |
344 KB |
Output is correct |
25 |
Correct |
17 ms |
436 KB |
Output is correct |
26 |
Correct |
23 ms |
608 KB |
Output is correct |
27 |
Correct |
1 ms |
344 KB |
Output is correct |
28 |
Partially correct |
28 ms |
696 KB |
Partially correct - number of queries: 6483 |
29 |
Correct |
22 ms |
696 KB |
Output is correct |
30 |
Partially correct |
36 ms |
440 KB |
Partially correct - number of queries: 7644 |
31 |
Correct |
1 ms |
344 KB |
Output is correct |
32 |
Correct |
2 ms |
344 KB |
Output is correct |
33 |
Correct |
1 ms |
344 KB |
Output is correct |
34 |
Correct |
13 ms |
440 KB |
Output is correct |
35 |
Correct |
1 ms |
344 KB |
Output is correct |
36 |
Correct |
8 ms |
440 KB |
Output is correct |
37 |
Correct |
1 ms |
344 KB |
Output is correct |
38 |
Correct |
1 ms |
544 KB |
Output is correct |
39 |
Correct |
13 ms |
444 KB |
Output is correct |
40 |
Partially correct |
27 ms |
692 KB |
Partially correct - number of queries: 6541 |
41 |
Correct |
23 ms |
444 KB |
Output is correct |
42 |
Correct |
24 ms |
448 KB |
Output is correct |
43 |
Correct |
17 ms |
676 KB |
Output is correct |
44 |
Correct |
17 ms |
680 KB |
Output is correct |
45 |
Correct |
11 ms |
444 KB |
Output is correct |
46 |
Correct |
1 ms |
344 KB |
Output is correct |
47 |
Correct |
14 ms |
692 KB |
Output is correct |
48 |
Partially correct |
29 ms |
440 KB |
Partially correct - number of queries: 5739 |
49 |
Correct |
4 ms |
344 KB |
Output is correct |
50 |
Partially correct |
37 ms |
696 KB |
Partially correct - number of queries: 7713 |
51 |
Correct |
12 ms |
444 KB |
Output is correct |
52 |
Correct |
1 ms |
344 KB |
Output is correct |
53 |
Correct |
1 ms |
344 KB |
Output is correct |
54 |
Correct |
13 ms |
440 KB |
Output is correct |
55 |
Correct |
1 ms |
344 KB |
Output is correct |
56 |
Partially correct |
41 ms |
696 KB |
Partially correct - number of queries: 7712 |
57 |
Partially correct |
24 ms |
676 KB |
Partially correct - number of queries: 5614 |
58 |
Correct |
20 ms |
696 KB |
Output is correct |
59 |
Correct |
22 ms |
448 KB |
Output is correct |
60 |
Correct |
19 ms |
440 KB |
Output is correct |
61 |
Correct |
2 ms |
756 KB |
Output is correct |
62 |
Correct |
1 ms |
344 KB |
Output is correct |
63 |
Correct |
1 ms |
344 KB |
Output is correct |
64 |
Correct |
1 ms |
344 KB |
Output is correct |
65 |
Correct |
1 ms |
344 KB |
Output is correct |
66 |
Correct |
2 ms |
712 KB |
Output is correct |
67 |
Correct |
1 ms |
344 KB |
Output is correct |
68 |
Correct |
3 ms |
960 KB |
Output is correct |
69 |
Correct |
2 ms |
700 KB |
Output is correct |
70 |
Correct |
1 ms |
344 KB |
Output is correct |
71 |
Partially correct |
34 ms |
688 KB |
Partially correct - number of queries: 7924 |
72 |
Correct |
6 ms |
344 KB |
Output is correct |
73 |
Partially correct |
40 ms |
444 KB |
Partially correct - number of queries: 7812 |
74 |
Partially correct |
40 ms |
444 KB |
Partially correct - number of queries: 7862 |
75 |
Correct |
1 ms |
344 KB |
Output is correct |
76 |
Partially correct |
31 ms |
440 KB |
Partially correct - number of queries: 6733 |
77 |
Partially correct |
37 ms |
600 KB |
Partially correct - number of queries: 7353 |
78 |
Correct |
3 ms |
344 KB |
Output is correct |
79 |
Correct |
15 ms |
444 KB |
Output is correct |
80 |
Partially correct |
35 ms |
696 KB |
Partially correct - number of queries: 7625 |
81 |
Partially correct |
40 ms |
936 KB |
Partially correct - number of queries: 7354 |
82 |
Partially correct |
36 ms |
932 KB |
Partially correct - number of queries: 7140 |
83 |
Correct |
1 ms |
344 KB |
Output is correct |
84 |
Partially correct |
37 ms |
1196 KB |
Partially correct - number of queries: 6111 |
85 |
Partially correct |
29 ms |
952 KB |
Partially correct - number of queries: 7005 |
86 |
Incorrect |
6 ms |
976 KB |
Integer -1 violates the range [0, 199999] |
87 |
Halted |
0 ms |
0 KB |
- |