#include<bits/stdc++.h>
#include "prize.h"
using namespace std;
const int MAX_VAL=200*1000+5;
int nbVal,nbPasMax,rep=-1;
set<int> memeSom[MAX_VAL];
vector<int> ans[MAX_VAL];
void calc(int deb,int fin) {
if (fin<deb or rep!=-1) {
return;
}
int mid=(deb+fin)/2;
ans[mid]=ask(mid);
int som=ans[mid][0]+ans[mid][1];
if (som==0) {
rep=mid;
}
memeSom[som].insert(mid);
auto it=memeSom[som].upper_bound(mid);
if ((*it)==MAX_VAL or ans[mid][0]!=ans[(*it)][0]) {
calc(mid+1,fin);
}
it=memeSom[som].lower_bound(mid);
it--;
if ((*it)==-MAX_VAL or ans[mid][0]!=ans[(*it)][0]) {
calc(deb,mid-1);
}
}
int find_best(int n) {
nbVal=n;
for (int i=0;i<nbVal;i++) {
memeSom[i].insert(MAX_VAL);
memeSom[i].insert(-MAX_VAL);
}
calc(0,nbVal-1);
return rep;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
33156 KB |
Output is correct |
2 |
Correct |
27 ms |
33208 KB |
Output is correct |
3 |
Correct |
27 ms |
33152 KB |
Output is correct |
4 |
Correct |
30 ms |
33064 KB |
Output is correct |
5 |
Correct |
26 ms |
33140 KB |
Output is correct |
6 |
Correct |
28 ms |
33156 KB |
Output is correct |
7 |
Correct |
26 ms |
33032 KB |
Output is correct |
8 |
Correct |
26 ms |
33140 KB |
Output is correct |
9 |
Correct |
26 ms |
33164 KB |
Output is correct |
10 |
Correct |
26 ms |
33080 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
33144 KB |
Output is correct |
2 |
Correct |
30 ms |
33252 KB |
Output is correct |
3 |
Correct |
26 ms |
33172 KB |
Output is correct |
4 |
Correct |
26 ms |
33096 KB |
Output is correct |
5 |
Correct |
29 ms |
33048 KB |
Output is correct |
6 |
Correct |
25 ms |
33104 KB |
Output is correct |
7 |
Correct |
38 ms |
33104 KB |
Output is correct |
8 |
Correct |
26 ms |
33104 KB |
Output is correct |
9 |
Correct |
25 ms |
33180 KB |
Output is correct |
10 |
Correct |
25 ms |
33076 KB |
Output is correct |
11 |
Correct |
30 ms |
33176 KB |
Output is correct |
12 |
Correct |
28 ms |
33200 KB |
Output is correct |
13 |
Correct |
31 ms |
33160 KB |
Output is correct |
14 |
Correct |
15 ms |
16368 KB |
Output is correct |
15 |
Correct |
41 ms |
33436 KB |
Output is correct |
16 |
Correct |
38 ms |
33192 KB |
Output is correct |
17 |
Correct |
53 ms |
33516 KB |
Output is correct |
18 |
Correct |
28 ms |
33036 KB |
Output is correct |
19 |
Correct |
47 ms |
33452 KB |
Output is correct |
20 |
Correct |
28 ms |
23892 KB |
Output is correct |
21 |
Correct |
52 ms |
33340 KB |
Output is correct |
22 |
Correct |
57 ms |
33344 KB |
Output is correct |
23 |
Correct |
26 ms |
33096 KB |
Output is correct |
24 |
Correct |
28 ms |
33160 KB |
Output is correct |
25 |
Correct |
51 ms |
33308 KB |
Output is correct |
26 |
Correct |
43 ms |
33204 KB |
Output is correct |
27 |
Correct |
25 ms |
33068 KB |
Output is correct |
28 |
Correct |
39 ms |
33120 KB |
Output is correct |
29 |
Correct |
31 ms |
33188 KB |
Output is correct |
30 |
Correct |
26 ms |
33072 KB |
Output is correct |
31 |
Correct |
59 ms |
33512 KB |
Output is correct |
32 |
Correct |
32 ms |
33104 KB |
Output is correct |
33 |
Correct |
6 ms |
14400 KB |
Output is correct |
34 |
Correct |
57 ms |
33328 KB |
Output is correct |
35 |
Correct |
30 ms |
33156 KB |
Output is correct |
36 |
Correct |
46 ms |
33380 KB |
Output is correct |
37 |
Correct |
42 ms |
33088 KB |
Output is correct |
38 |
Correct |
27 ms |
33060 KB |
Output is correct |
39 |
Correct |
46 ms |
33348 KB |
Output is correct |
40 |
Correct |
26 ms |
33064 KB |
Output is correct |
41 |
Correct |
43 ms |
33196 KB |
Output is correct |
42 |
Correct |
60 ms |
33224 KB |
Output is correct |
43 |
Correct |
41 ms |
33308 KB |
Output is correct |
44 |
Correct |
49 ms |
33364 KB |
Output is correct |
45 |
Correct |
54 ms |
33312 KB |
Output is correct |
46 |
Correct |
61 ms |
33428 KB |
Output is correct |
47 |
Correct |
53 ms |
33312 KB |
Output is correct |
48 |
Correct |
35 ms |
33224 KB |
Output is correct |
49 |
Correct |
50 ms |
33448 KB |
Output is correct |
50 |
Correct |
31 ms |
33068 KB |
Output is correct |
51 |
Correct |
57 ms |
33324 KB |
Output is correct |
52 |
Correct |
72 ms |
33464 KB |
Output is correct |
53 |
Correct |
30 ms |
33156 KB |
Output is correct |
54 |
Correct |
53 ms |
33352 KB |
Output is correct |
55 |
Correct |
56 ms |
33484 KB |
Output is correct |
56 |
Correct |
31 ms |
33096 KB |
Output is correct |
57 |
Correct |
39 ms |
33192 KB |
Output is correct |
58 |
Correct |
47 ms |
33204 KB |
Output is correct |
59 |
Correct |
44 ms |
33216 KB |
Output is correct |
60 |
Correct |
45 ms |
33272 KB |
Output is correct |
61 |
Correct |
27 ms |
33104 KB |
Output is correct |
62 |
Correct |
28 ms |
33116 KB |
Output is correct |
63 |
Correct |
26 ms |
33144 KB |
Output is correct |
64 |
Correct |
33 ms |
33064 KB |
Output is correct |
65 |
Correct |
27 ms |
33060 KB |
Output is correct |
66 |
Correct |
31 ms |
33072 KB |
Output is correct |
67 |
Correct |
38 ms |
33076 KB |
Output is correct |
68 |
Correct |
31 ms |
33068 KB |
Output is correct |
69 |
Correct |
25 ms |
33036 KB |
Output is correct |
70 |
Correct |
26 ms |
33060 KB |
Output is correct |
71 |
Correct |
57 ms |
33408 KB |
Output is correct |
72 |
Correct |
39 ms |
33188 KB |
Output is correct |
73 |
Correct |
67 ms |
33504 KB |
Output is correct |
74 |
Correct |
65 ms |
33424 KB |
Output is correct |
75 |
Correct |
29 ms |
33152 KB |
Output is correct |
76 |
Correct |
62 ms |
33368 KB |
Output is correct |
77 |
Correct |
67 ms |
33456 KB |
Output is correct |
78 |
Correct |
31 ms |
33096 KB |
Output is correct |
79 |
Correct |
50 ms |
33316 KB |
Output is correct |
80 |
Correct |
70 ms |
33404 KB |
Output is correct |
81 |
Correct |
66 ms |
33520 KB |
Output is correct |
82 |
Correct |
68 ms |
33488 KB |
Output is correct |
83 |
Correct |
25 ms |
33132 KB |
Output is correct |
84 |
Correct |
70 ms |
33456 KB |
Output is correct |
85 |
Correct |
66 ms |
33512 KB |
Output is correct |
86 |
Correct |
30 ms |
33188 KB |
Output is correct |
87 |
Correct |
27 ms |
33072 KB |
Output is correct |
88 |
Correct |
29 ms |
33160 KB |
Output is correct |
89 |
Correct |
29 ms |
33176 KB |
Output is correct |
90 |
Correct |
31 ms |
33172 KB |
Output is correct |
91 |
Correct |
28 ms |
33092 KB |
Output is correct |
92 |
Correct |
36 ms |
33044 KB |
Output is correct |
93 |
Correct |
33 ms |
33056 KB |
Output is correct |
94 |
Correct |
30 ms |
33104 KB |
Output is correct |
95 |
Correct |
34 ms |
33096 KB |
Output is correct |
96 |
Correct |
28 ms |
33180 KB |
Output is correct |
97 |
Correct |
30 ms |
33080 KB |
Output is correct |