#include "prize.h"
#include<bits/stdc++.h>
using namespace std;
map<int,pair<int,int>>mp;
int cnta=0;
pair<int,int>pors(int u){
if(mp.count(u)==0){
cnta++;
if(cnta>=10000){
exit(23);
}
vector<int>hey=ask(u);
mp[u]=make_pair(hey[0],hey[1]);
}
return mp[u];
}
int find_best(int n) {
mp.clear();
int cnta=0;
for(int i=0;i<n;){
//cout<<i<<endl;
pair<int,int>av=pors(i);
if(av.first+av.second==0){
return i;
}
cnta++;
pair<int,int>fake;
int low=i,high=n,mid,f=0;
for(auto x:mp){
mid=x.first;
fake=pors(mid);
if(fake.first+fake.second!=av.first+av.second){
if(fake.first+fake.second>av.first+av.second){
f=1;
break;
}
high=mid;
}else{
if(fake.first-av.first==0){
low=mid;
}else{
high=mid;
}
}
}
if(f){
i=low+1;
continue;
}
low=max(low,i);
high=n;
while(high-low>1){
mid=(high+low)>>1;
fake=pors(mid);
if(fake.first+fake.second!=av.first+av.second){
if(fake.first+fake.second>av.first+av.second){
break;
}
high=mid;
}else{
if(fake.first-av.first==0){
low=mid;
}else{
high=mid;
}
}
}
i=low+1;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 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 |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
428 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
432 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
3 ms |
344 KB |
Output is correct |
14 |
Correct |
2 ms |
344 KB |
Output is correct |
15 |
Correct |
6 ms |
428 KB |
Output is correct |
16 |
Partially correct |
130 ms |
848 KB |
Partially correct - number of queries: 6423 |
17 |
Correct |
0 ms |
340 KB |
Output is correct |
18 |
Partially correct |
197 ms |
1488 KB |
Partially correct - number of queries: 7529 |
19 |
Correct |
0 ms |
344 KB |
Output is correct |
20 |
Correct |
14 ms |
684 KB |
Output is correct |
21 |
Correct |
30 ms |
344 KB |
Output is correct |
22 |
Correct |
3 ms |
344 KB |
Output is correct |
23 |
Correct |
0 ms |
344 KB |
Output is correct |
24 |
Correct |
0 ms |
428 KB |
Output is correct |
25 |
Correct |
63 ms |
592 KB |
Output is correct |
26 |
Correct |
59 ms |
856 KB |
Output is correct |
27 |
Correct |
1 ms |
344 KB |
Output is correct |
28 |
Partially correct |
174 ms |
920 KB |
Partially correct - number of queries: 7236 |
29 |
Partially correct |
94 ms |
600 KB |
Partially correct - number of queries: 5524 |
30 |
Partially correct |
189 ms |
976 KB |
Partially correct - number of queries: 7450 |
31 |
Correct |
0 ms |
344 KB |
Output is correct |
32 |
Correct |
2 ms |
344 KB |
Output is correct |
33 |
Correct |
0 ms |
344 KB |
Output is correct |
34 |
Correct |
21 ms |
504 KB |
Output is correct |
35 |
Correct |
1 ms |
344 KB |
Output is correct |
36 |
Correct |
14 ms |
344 KB |
Output is correct |
37 |
Correct |
1 ms |
344 KB |
Output is correct |
38 |
Correct |
0 ms |
344 KB |
Output is correct |
39 |
Correct |
40 ms |
596 KB |
Output is correct |
40 |
Partially correct |
139 ms |
688 KB |
Partially correct - number of queries: 6397 |
41 |
Correct |
62 ms |
644 KB |
Output is correct |
42 |
Correct |
69 ms |
744 KB |
Output is correct |
43 |
Correct |
50 ms |
600 KB |
Output is correct |
44 |
Correct |
33 ms |
580 KB |
Output is correct |
45 |
Correct |
20 ms |
344 KB |
Output is correct |
46 |
Correct |
1 ms |
344 KB |
Output is correct |
47 |
Correct |
43 ms |
856 KB |
Output is correct |
48 |
Partially correct |
94 ms |
608 KB |
Partially correct - number of queries: 5588 |
49 |
Correct |
4 ms |
600 KB |
Output is correct |
50 |
Partially correct |
174 ms |
1024 KB |
Partially correct - number of queries: 7532 |
51 |
Correct |
42 ms |
680 KB |
Output is correct |
52 |
Correct |
1 ms |
344 KB |
Output is correct |
53 |
Correct |
1 ms |
344 KB |
Output is correct |
54 |
Correct |
34 ms |
564 KB |
Output is correct |
55 |
Correct |
0 ms |
344 KB |
Output is correct |
56 |
Partially correct |
190 ms |
1048 KB |
Partially correct - number of queries: 7532 |
57 |
Partially correct |
95 ms |
864 KB |
Partially correct - number of queries: 5490 |
58 |
Partially correct |
92 ms |
932 KB |
Partially correct - number of queries: 5582 |
59 |
Correct |
62 ms |
568 KB |
Output is correct |
60 |
Correct |
56 ms |
844 KB |
Output is correct |
61 |
Correct |
1 ms |
344 KB |
Output is correct |
62 |
Correct |
0 ms |
344 KB |
Output is correct |
63 |
Correct |
1 ms |
344 KB |
Output is correct |
64 |
Correct |
0 ms |
344 KB |
Output is correct |
65 |
Correct |
0 ms |
424 KB |
Output is correct |
66 |
Correct |
2 ms |
344 KB |
Output is correct |
67 |
Correct |
0 ms |
428 KB |
Output is correct |
68 |
Correct |
7 ms |
344 KB |
Output is correct |
69 |
Correct |
3 ms |
344 KB |
Output is correct |
70 |
Correct |
0 ms |
344 KB |
Output is correct |
71 |
Partially correct |
190 ms |
880 KB |
Partially correct - number of queries: 7398 |
72 |
Correct |
4 ms |
340 KB |
Output is correct |
73 |
Partially correct |
172 ms |
1068 KB |
Partially correct - number of queries: 7242 |
74 |
Partially correct |
188 ms |
856 KB |
Partially correct - number of queries: 7313 |
75 |
Correct |
1 ms |
344 KB |
Output is correct |
76 |
Partially correct |
144 ms |
764 KB |
Partially correct - number of queries: 6365 |
77 |
Partially correct |
203 ms |
848 KB |
Partially correct - number of queries: 7519 |
78 |
Correct |
3 ms |
344 KB |
Output is correct |
79 |
Correct |
41 ms |
600 KB |
Output is correct |
80 |
Partially correct |
178 ms |
1104 KB |
Partially correct - number of queries: 7543 |
81 |
Partially correct |
187 ms |
800 KB |
Partially correct - number of queries: 7487 |
82 |
Partially correct |
178 ms |
900 KB |
Partially correct - number of queries: 7475 |
83 |
Correct |
1 ms |
344 KB |
Output is correct |
84 |
Partially correct |
123 ms |
828 KB |
Partially correct - number of queries: 6195 |
85 |
Partially correct |
186 ms |
1048 KB |
Partially correct - number of queries: 7501 |
86 |
Partially correct |
142 ms |
792 KB |
Partially correct - number of queries: 6419 |
87 |
Correct |
3 ms |
600 KB |
Output is correct |
88 |
Partially correct |
129 ms |
840 KB |
Partially correct - number of queries: 6076 |
89 |
Partially correct |
143 ms |
1244 KB |
Partially correct - number of queries: 6399 |
90 |
Correct |
1 ms |
344 KB |
Output is correct |
91 |
Correct |
55 ms |
1036 KB |
Output is correct |
92 |
Correct |
0 ms |
344 KB |
Output is correct |
93 |
Correct |
3 ms |
448 KB |
Output is correct |
94 |
Correct |
3 ms |
344 KB |
Output is correct |
95 |
Correct |
3 ms |
460 KB |
Output is correct |
96 |
Correct |
3 ms |
344 KB |
Output is correct |
97 |
Correct |
1 ms |
344 KB |
Output is correct |