#include "prize.h"
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back
using namespace std;
int find_best(int n) {
int x = 472;
int mx = -1e9, mni;
for(int i = 0; i < min(x, n); i++){
vector <int> v = ask(i);
if(v[0] == 0 && v[1] == 0){
return i;
}
if(v[0] + v[1] > mx)
mx = v[0] + v[1], mni = i;
}
int cur = mni;
int cnt = 0;
vector <int> a = ask(mni);
while(true){
int l = cur, r = n;
//vector <int> a = ask(mni);
//if(a[1] - cnt == o[1]) break;
while(l + 1 < r){
int mid = (l + r) / 2;
vector <int> o = ask(mid);
if(a[1] - cnt == o[1]) l = mid;
else r = mid;
}
cur = r;
if(r == n) break;
vector <int> o = ask(r);
if(o[0] == 0 && o[1] == 0) return r;
cnt++;
}
return 0;
}
Compilation message
prize.cpp: In function 'int find_best(int)':
prize.cpp:26:26: warning: 'mni' may be used uninitialized in this function [-Wmaybe-uninitialized]
26 | vector <int> a = ask(mni);
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
208 KB |
Output is correct |
2 |
Correct |
2 ms |
336 KB |
Output is correct |
3 |
Correct |
4 ms |
208 KB |
Output is correct |
4 |
Correct |
4 ms |
288 KB |
Output is correct |
5 |
Correct |
4 ms |
208 KB |
Output is correct |
6 |
Correct |
0 ms |
208 KB |
Output is correct |
7 |
Correct |
4 ms |
208 KB |
Output is correct |
8 |
Correct |
4 ms |
256 KB |
Output is correct |
9 |
Correct |
3 ms |
208 KB |
Output is correct |
10 |
Correct |
4 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
208 KB |
Output is correct |
2 |
Correct |
3 ms |
208 KB |
Output is correct |
3 |
Correct |
2 ms |
288 KB |
Output is correct |
4 |
Correct |
4 ms |
208 KB |
Output is correct |
5 |
Correct |
3 ms |
208 KB |
Output is correct |
6 |
Correct |
0 ms |
208 KB |
Output is correct |
7 |
Correct |
3 ms |
208 KB |
Output is correct |
8 |
Correct |
4 ms |
208 KB |
Output is correct |
9 |
Correct |
2 ms |
208 KB |
Output is correct |
10 |
Correct |
3 ms |
208 KB |
Output is correct |
11 |
Correct |
5 ms |
208 KB |
Output is correct |
12 |
Correct |
4 ms |
208 KB |
Output is correct |
13 |
Correct |
7 ms |
208 KB |
Output is correct |
14 |
Correct |
6 ms |
208 KB |
Output is correct |
15 |
Correct |
13 ms |
208 KB |
Output is correct |
16 |
Partially correct |
45 ms |
292 KB |
Partially correct - number of queries: 7412 |
17 |
Correct |
3 ms |
208 KB |
Output is correct |
18 |
Partially correct |
55 ms |
288 KB |
Partially correct - number of queries: 8613 |
19 |
Correct |
4 ms |
208 KB |
Output is correct |
20 |
Correct |
8 ms |
288 KB |
Output is correct |
21 |
Correct |
24 ms |
208 KB |
Output is correct |
22 |
Correct |
6 ms |
208 KB |
Output is correct |
23 |
Correct |
3 ms |
272 KB |
Output is correct |
24 |
Correct |
4 ms |
208 KB |
Output is correct |
25 |
Partially correct |
34 ms |
208 KB |
Partially correct - number of queries: 5103 |
26 |
Partially correct |
29 ms |
208 KB |
Partially correct - number of queries: 5064 |
27 |
Correct |
3 ms |
208 KB |
Output is correct |
28 |
Partially correct |
47 ms |
208 KB |
Partially correct - number of queries: 8242 |
29 |
Partially correct |
41 ms |
208 KB |
Partially correct - number of queries: 6350 |
30 |
Partially correct |
34 ms |
336 KB |
Partially correct - number of queries: 8541 |
31 |
Correct |
4 ms |
208 KB |
Output is correct |
32 |
Correct |
5 ms |
292 KB |
Output is correct |
33 |
Correct |
1 ms |
208 KB |
Output is correct |
34 |
Correct |
18 ms |
208 KB |
Output is correct |
35 |
Correct |
3 ms |
336 KB |
Output is correct |
36 |
Correct |
18 ms |
208 KB |
Output is correct |
37 |
Correct |
6 ms |
208 KB |
Output is correct |
38 |
Correct |
2 ms |
208 KB |
Output is correct |
39 |
Correct |
21 ms |
208 KB |
Output is correct |
40 |
Partially correct |
43 ms |
208 KB |
Partially correct - number of queries: 7363 |
41 |
Partially correct |
35 ms |
288 KB |
Partially correct - number of queries: 5351 |
42 |
Partially correct |
31 ms |
212 KB |
Partially correct - number of queries: 5351 |
43 |
Correct |
41 ms |
208 KB |
Output is correct |
44 |
Correct |
25 ms |
208 KB |
Output is correct |
45 |
Correct |
27 ms |
208 KB |
Output is correct |
46 |
Correct |
4 ms |
208 KB |
Output is correct |
47 |
Correct |
36 ms |
208 KB |
Output is correct |
48 |
Partially correct |
67 ms |
292 KB |
Partially correct - number of queries: 6497 |
49 |
Correct |
5 ms |
208 KB |
Output is correct |
50 |
Partially correct |
56 ms |
208 KB |
Partially correct - number of queries: 8607 |
51 |
Correct |
20 ms |
208 KB |
Output is correct |
52 |
Correct |
3 ms |
288 KB |
Output is correct |
53 |
Correct |
6 ms |
208 KB |
Output is correct |
54 |
Correct |
14 ms |
296 KB |
Output is correct |
55 |
Correct |
4 ms |
208 KB |
Output is correct |
56 |
Partially correct |
54 ms |
208 KB |
Partially correct - number of queries: 8606 |
57 |
Partially correct |
46 ms |
208 KB |
Partially correct - number of queries: 6417 |
58 |
Partially correct |
30 ms |
208 KB |
Partially correct - number of queries: 6516 |
59 |
Partially correct |
19 ms |
292 KB |
Partially correct - number of queries: 5351 |
60 |
Correct |
36 ms |
208 KB |
Output is correct |
61 |
Correct |
5 ms |
208 KB |
Output is correct |
62 |
Correct |
2 ms |
300 KB |
Output is correct |
63 |
Correct |
5 ms |
208 KB |
Output is correct |
64 |
Correct |
2 ms |
208 KB |
Output is correct |
65 |
Correct |
4 ms |
208 KB |
Output is correct |
66 |
Correct |
31 ms |
208 KB |
Output is correct |
67 |
Correct |
2 ms |
288 KB |
Output is correct |
68 |
Correct |
5 ms |
208 KB |
Output is correct |
69 |
Correct |
20 ms |
292 KB |
Output is correct |
70 |
Correct |
6 ms |
208 KB |
Output is correct |
71 |
Partially correct |
58 ms |
208 KB |
Partially correct - number of queries: 8745 |
72 |
Correct |
4 ms |
208 KB |
Output is correct |
73 |
Partially correct |
53 ms |
208 KB |
Partially correct - number of queries: 8633 |
74 |
Partially correct |
48 ms |
208 KB |
Partially correct - number of queries: 8691 |
75 |
Correct |
6 ms |
208 KB |
Output is correct |
76 |
Partially correct |
62 ms |
208 KB |
Partially correct - number of queries: 7501 |
77 |
Partially correct |
69 ms |
208 KB |
Partially correct - number of queries: 8618 |
78 |
Correct |
4 ms |
208 KB |
Output is correct |
79 |
Correct |
32 ms |
208 KB |
Output is correct |
80 |
Partially correct |
71 ms |
208 KB |
Partially correct - number of queries: 8616 |
81 |
Partially correct |
49 ms |
208 KB |
Partially correct - number of queries: 8635 |
82 |
Partially correct |
51 ms |
208 KB |
Partially correct - number of queries: 8569 |
83 |
Correct |
6 ms |
208 KB |
Output is correct |
84 |
Partially correct |
62 ms |
208 KB |
Partially correct - number of queries: 7139 |
85 |
Partially correct |
66 ms |
208 KB |
Partially correct - number of queries: 8629 |
86 |
Correct |
5 ms |
208 KB |
Output is correct |
87 |
Correct |
3 ms |
208 KB |
Output is correct |
88 |
Correct |
5 ms |
208 KB |
Output is correct |
89 |
Correct |
5 ms |
208 KB |
Output is correct |
90 |
Correct |
3 ms |
208 KB |
Output is correct |
91 |
Correct |
4 ms |
208 KB |
Output is correct |
92 |
Correct |
5 ms |
332 KB |
Output is correct |
93 |
Correct |
9 ms |
208 KB |
Output is correct |
94 |
Correct |
6 ms |
208 KB |
Output is correct |
95 |
Correct |
6 ms |
208 KB |
Output is correct |
96 |
Correct |
5 ms |
208 KB |
Output is correct |
97 |
Correct |
4 ms |
208 KB |
Output is correct |