#include <bits/stdc++.h>
#include "prize.h"
using namespace std;
const int MAXN = 2e5 + 5;
int find_best(int n){
int sum = 0, p = 500;
for(int i=0; i<min(n, 500); ++i){
vector<int> v = ask(i);
sum = max(sum, v[0] + v[1]);
if(v[0] + v[1] == 0) return i;
}
while(p < n){
vector<int> v = ask(p);
if(v[0] + v[1] == 0) return p;
int lo = p + 1, hi = n - 1, mid;
if(v[0] + v[1] == sum){
while(lo <= hi){
mid = (lo + hi)/2;
vector<int> ans = ask(mid);
if(ans[0] + ans[1] == 0) return mid;
if(lo == hi) break;
if(ans[0] + ans[1] < sum) hi = mid;
else{
if(v[1] - ans[1] > 0) hi = mid - 1;
else lo = mid + 1;
}
}
p = lo + 1;
}
else p++;
}
}
Compilation message
prize.cpp: In function 'int find_best(int)':
prize.cpp:35:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
248 KB |
Output is correct |
2 |
Correct |
7 ms |
436 KB |
Output is correct |
3 |
Correct |
8 ms |
540 KB |
Output is correct |
4 |
Correct |
6 ms |
540 KB |
Output is correct |
5 |
Correct |
4 ms |
540 KB |
Output is correct |
6 |
Correct |
2 ms |
540 KB |
Output is correct |
7 |
Correct |
5 ms |
540 KB |
Output is correct |
8 |
Correct |
7 ms |
544 KB |
Output is correct |
9 |
Correct |
5 ms |
544 KB |
Output is correct |
10 |
Correct |
5 ms |
544 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
552 KB |
Output is correct |
2 |
Correct |
6 ms |
552 KB |
Output is correct |
3 |
Correct |
6 ms |
552 KB |
Output is correct |
4 |
Correct |
3 ms |
552 KB |
Output is correct |
5 |
Correct |
6 ms |
552 KB |
Output is correct |
6 |
Correct |
2 ms |
552 KB |
Output is correct |
7 |
Correct |
6 ms |
552 KB |
Output is correct |
8 |
Correct |
6 ms |
552 KB |
Output is correct |
9 |
Correct |
6 ms |
552 KB |
Output is correct |
10 |
Correct |
6 ms |
552 KB |
Output is correct |
11 |
Correct |
9 ms |
552 KB |
Output is correct |
12 |
Correct |
5 ms |
552 KB |
Output is correct |
13 |
Correct |
6 ms |
552 KB |
Output is correct |
14 |
Correct |
7 ms |
552 KB |
Output is correct |
15 |
Correct |
15 ms |
552 KB |
Output is correct |
16 |
Partially correct |
58 ms |
556 KB |
Partially correct - number of queries: 7575 |
17 |
Correct |
4 ms |
556 KB |
Output is correct |
18 |
Partially correct |
67 ms |
556 KB |
Partially correct - number of queries: 8808 |
19 |
Correct |
3 ms |
556 KB |
Output is correct |
20 |
Correct |
17 ms |
556 KB |
Output is correct |
21 |
Correct |
31 ms |
556 KB |
Output is correct |
22 |
Correct |
10 ms |
556 KB |
Output is correct |
23 |
Correct |
5 ms |
556 KB |
Output is correct |
24 |
Correct |
4 ms |
556 KB |
Output is correct |
25 |
Partially correct |
30 ms |
556 KB |
Partially correct - number of queries: 5174 |
26 |
Partially correct |
40 ms |
556 KB |
Partially correct - number of queries: 5113 |
27 |
Correct |
8 ms |
556 KB |
Output is correct |
28 |
Partially correct |
33 ms |
572 KB |
Partially correct - number of queries: 8385 |
29 |
Partially correct |
27 ms |
572 KB |
Partially correct - number of queries: 6460 |
30 |
Partially correct |
82 ms |
572 KB |
Partially correct - number of queries: 8742 |
31 |
Correct |
5 ms |
572 KB |
Output is correct |
32 |
Correct |
9 ms |
572 KB |
Output is correct |
33 |
Correct |
2 ms |
572 KB |
Output is correct |
34 |
Correct |
14 ms |
572 KB |
Output is correct |
35 |
Correct |
8 ms |
572 KB |
Output is correct |
36 |
Correct |
23 ms |
572 KB |
Output is correct |
37 |
Correct |
6 ms |
572 KB |
Output is correct |
38 |
Correct |
4 ms |
572 KB |
Output is correct |
39 |
Correct |
45 ms |
572 KB |
Output is correct |
40 |
Partially correct |
79 ms |
572 KB |
Partially correct - number of queries: 7542 |
41 |
Partially correct |
53 ms |
572 KB |
Partially correct - number of queries: 5455 |
42 |
Partially correct |
41 ms |
572 KB |
Partially correct - number of queries: 5455 |
43 |
Correct |
53 ms |
572 KB |
Output is correct |
44 |
Correct |
29 ms |
572 KB |
Output is correct |
45 |
Correct |
32 ms |
572 KB |
Output is correct |
46 |
Correct |
4 ms |
572 KB |
Output is correct |
47 |
Correct |
43 ms |
572 KB |
Output is correct |
48 |
Partially correct |
47 ms |
572 KB |
Partially correct - number of queries: 6634 |
49 |
Correct |
7 ms |
572 KB |
Output is correct |
50 |
Partially correct |
85 ms |
572 KB |
Partially correct - number of queries: 8797 |
51 |
Correct |
33 ms |
572 KB |
Output is correct |
52 |
Correct |
8 ms |
572 KB |
Output is correct |
53 |
Correct |
7 ms |
572 KB |
Output is correct |
54 |
Correct |
17 ms |
572 KB |
Output is correct |
55 |
Correct |
6 ms |
572 KB |
Output is correct |
56 |
Partially correct |
75 ms |
572 KB |
Partially correct - number of queries: 8797 |
57 |
Partially correct |
38 ms |
572 KB |
Partially correct - number of queries: 6560 |
58 |
Partially correct |
66 ms |
572 KB |
Partially correct - number of queries: 6661 |
59 |
Partially correct |
45 ms |
572 KB |
Partially correct - number of queries: 5455 |
60 |
Partially correct |
48 ms |
572 KB |
Partially correct - number of queries: 5098 |
61 |
Correct |
7 ms |
572 KB |
Output is correct |
62 |
Correct |
4 ms |
576 KB |
Output is correct |
63 |
Correct |
7 ms |
576 KB |
Output is correct |
64 |
Correct |
4 ms |
576 KB |
Output is correct |
65 |
Correct |
5 ms |
576 KB |
Output is correct |
66 |
Correct |
9 ms |
576 KB |
Output is correct |
67 |
Correct |
8 ms |
576 KB |
Output is correct |
68 |
Correct |
5 ms |
576 KB |
Output is correct |
69 |
Correct |
13 ms |
576 KB |
Output is correct |
70 |
Correct |
6 ms |
576 KB |
Output is correct |
71 |
Partially correct |
79 ms |
576 KB |
Partially correct - number of queries: 8756 |
72 |
Correct |
8 ms |
576 KB |
Output is correct |
73 |
Partially correct |
58 ms |
576 KB |
Partially correct - number of queries: 8648 |
74 |
Partially correct |
66 ms |
576 KB |
Partially correct - number of queries: 8696 |
75 |
Correct |
7 ms |
576 KB |
Output is correct |
76 |
Partially correct |
30 ms |
576 KB |
Partially correct - number of queries: 7560 |
77 |
Partially correct |
79 ms |
576 KB |
Partially correct - number of queries: 8823 |
78 |
Correct |
10 ms |
576 KB |
Output is correct |
79 |
Correct |
19 ms |
576 KB |
Output is correct |
80 |
Partially correct |
70 ms |
576 KB |
Partially correct - number of queries: 8836 |
81 |
Partially correct |
70 ms |
576 KB |
Partially correct - number of queries: 8841 |
82 |
Partially correct |
76 ms |
576 KB |
Partially correct - number of queries: 8737 |
83 |
Correct |
4 ms |
576 KB |
Output is correct |
84 |
Partially correct |
31 ms |
576 KB |
Partially correct - number of queries: 7276 |
85 |
Partially correct |
83 ms |
576 KB |
Partially correct - number of queries: 8800 |
86 |
Correct |
6 ms |
576 KB |
Output is correct |
87 |
Correct |
4 ms |
576 KB |
Output is correct |
88 |
Correct |
6 ms |
576 KB |
Output is correct |
89 |
Correct |
6 ms |
576 KB |
Output is correct |
90 |
Correct |
5 ms |
576 KB |
Output is correct |
91 |
Correct |
5 ms |
576 KB |
Output is correct |
92 |
Correct |
5 ms |
576 KB |
Output is correct |
93 |
Correct |
5 ms |
576 KB |
Output is correct |
94 |
Correct |
8 ms |
576 KB |
Output is correct |
95 |
Correct |
9 ms |
576 KB |
Output is correct |
96 |
Correct |
7 ms |
576 KB |
Output is correct |
97 |
Correct |
4 ms |
576 KB |
Output is correct |