#include "prize.h"
#include <bits/stdc++.h>
using namespace std;
// int N;
// vector <int> nums;
// vector <int> ask(int i) {
// vector <int> ans(2, 0);
// for (int j = 0; j < i; j++) {
// if (nums[j] > nums[i])
// ans[0]++;
// }
// for (int j = i+1; j < N; j++) {
// if (nums[j] > nums[i])
// ans[1]++;
// }
// return ans;
// }
int find_best(int n){
vector <vector <int>> p(n, {-1, -1});
int mx = 0, idx = 0;
for (int i = 0; i < 500; i++) {
p[i] = ask(i);
if (p[i][0] + p[i][1] == 0)
return i;
if (mx < p[i][0] + p[i][1]) {
mx = p[i][0] + p[i][1];
idx = i;
}
}
for (int i = idx; i < n; i++) {
if (p[i][0] == -1)
p[i] = ask(i);
if (p[i][0] + p[i][1] == 0)
return i;
if (p[i][0] + p[i][1] < mx)
continue;
int lo = i-1, hi = n-1;
while (lo < hi) {
int mid = lo + (hi - lo + 1) / 2;
if (p[mid][0] == -1) {
p[mid] = ask(mid);
}
vector <int> res = p[mid];
if (res == p[i])
lo = mid;
else
hi = mid - 1;
}
i = lo;
}
return 0;
}
// int main() {
// cin >> N;
// nums.resize(N+1);
// for (int i = 0; i < N; i++)
// cin >> nums[i];
// find_best(N);
// }
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
11352 KB |
Output is correct |
2 |
Correct |
11 ms |
11352 KB |
Output is correct |
3 |
Correct |
9 ms |
11196 KB |
Output is correct |
4 |
Correct |
11 ms |
11348 KB |
Output is correct |
5 |
Correct |
11 ms |
11352 KB |
Output is correct |
6 |
Correct |
11 ms |
11352 KB |
Output is correct |
7 |
Correct |
10 ms |
11352 KB |
Output is correct |
8 |
Correct |
13 ms |
11396 KB |
Output is correct |
9 |
Correct |
12 ms |
11352 KB |
Output is correct |
10 |
Correct |
10 ms |
11352 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
11352 KB |
Output is correct |
2 |
Correct |
12 ms |
11352 KB |
Output is correct |
3 |
Correct |
13 ms |
11352 KB |
Output is correct |
4 |
Correct |
11 ms |
11352 KB |
Output is correct |
5 |
Correct |
11 ms |
11352 KB |
Output is correct |
6 |
Correct |
8 ms |
11352 KB |
Output is correct |
7 |
Correct |
11 ms |
11352 KB |
Output is correct |
8 |
Correct |
18 ms |
11352 KB |
Output is correct |
9 |
Correct |
11 ms |
11352 KB |
Output is correct |
10 |
Correct |
10 ms |
11352 KB |
Output is correct |
11 |
Correct |
16 ms |
11352 KB |
Output is correct |
12 |
Correct |
10 ms |
11352 KB |
Output is correct |
13 |
Correct |
13 ms |
11352 KB |
Output is correct |
14 |
Correct |
3 ms |
1368 KB |
Output is correct |
15 |
Correct |
16 ms |
11180 KB |
Output is correct |
16 |
Partially correct |
45 ms |
11352 KB |
Partially correct - number of queries: 7218 |
17 |
Correct |
13 ms |
11352 KB |
Output is correct |
18 |
Partially correct |
55 ms |
11352 KB |
Partially correct - number of queries: 8378 |
19 |
Correct |
10 ms |
11352 KB |
Output is correct |
20 |
Correct |
16 ms |
5720 KB |
Output is correct |
21 |
Correct |
30 ms |
11352 KB |
Output is correct |
22 |
Correct |
13 ms |
11352 KB |
Output is correct |
23 |
Correct |
11 ms |
11352 KB |
Output is correct |
24 |
Correct |
11 ms |
11352 KB |
Output is correct |
25 |
Correct |
31 ms |
11352 KB |
Output is correct |
26 |
Correct |
42 ms |
11352 KB |
Output is correct |
27 |
Correct |
14 ms |
11352 KB |
Output is correct |
28 |
Partially correct |
68 ms |
11352 KB |
Partially correct - number of queries: 7903 |
29 |
Partially correct |
52 ms |
11352 KB |
Partially correct - number of queries: 6143 |
30 |
Partially correct |
49 ms |
11156 KB |
Partially correct - number of queries: 8307 |
31 |
Correct |
10 ms |
11352 KB |
Output is correct |
32 |
Correct |
13 ms |
11352 KB |
Output is correct |
33 |
Correct |
0 ms |
344 KB |
Output is correct |
34 |
Correct |
25 ms |
11176 KB |
Output is correct |
35 |
Correct |
11 ms |
11352 KB |
Output is correct |
36 |
Correct |
19 ms |
11352 KB |
Output is correct |
37 |
Correct |
11 ms |
11208 KB |
Output is correct |
38 |
Correct |
11 ms |
11232 KB |
Output is correct |
39 |
Correct |
34 ms |
11352 KB |
Output is correct |
40 |
Partially correct |
53 ms |
11352 KB |
Partially correct - number of queries: 7178 |
41 |
Partially correct |
40 ms |
11352 KB |
Partially correct - number of queries: 5238 |
42 |
Partially correct |
30 ms |
11352 KB |
Partially correct - number of queries: 5238 |
43 |
Correct |
31 ms |
11352 KB |
Output is correct |
44 |
Correct |
25 ms |
11352 KB |
Output is correct |
45 |
Correct |
23 ms |
11352 KB |
Output is correct |
46 |
Correct |
14 ms |
11352 KB |
Output is correct |
47 |
Correct |
33 ms |
11352 KB |
Output is correct |
48 |
Partially correct |
52 ms |
11348 KB |
Partially correct - number of queries: 6334 |
49 |
Correct |
13 ms |
11352 KB |
Output is correct |
50 |
Partially correct |
55 ms |
11348 KB |
Partially correct - number of queries: 8379 |
51 |
Correct |
23 ms |
11352 KB |
Output is correct |
52 |
Correct |
11 ms |
11352 KB |
Output is correct |
53 |
Correct |
11 ms |
11352 KB |
Output is correct |
54 |
Correct |
32 ms |
11352 KB |
Output is correct |
55 |
Correct |
10 ms |
11352 KB |
Output is correct |
56 |
Partially correct |
57 ms |
11352 KB |
Partially correct - number of queries: 8374 |
57 |
Partially correct |
59 ms |
11352 KB |
Partially correct - number of queries: 6238 |
58 |
Partially correct |
37 ms |
11352 KB |
Partially correct - number of queries: 6320 |
59 |
Partially correct |
38 ms |
11352 KB |
Partially correct - number of queries: 5235 |
60 |
Correct |
39 ms |
11352 KB |
Output is correct |
61 |
Correct |
10 ms |
11352 KB |
Output is correct |
62 |
Correct |
13 ms |
11352 KB |
Output is correct |
63 |
Correct |
9 ms |
11352 KB |
Output is correct |
64 |
Correct |
13 ms |
11352 KB |
Output is correct |
65 |
Correct |
12 ms |
11352 KB |
Output is correct |
66 |
Correct |
14 ms |
11352 KB |
Output is correct |
67 |
Correct |
10 ms |
11352 KB |
Output is correct |
68 |
Correct |
10 ms |
11352 KB |
Output is correct |
69 |
Correct |
14 ms |
11352 KB |
Output is correct |
70 |
Correct |
11 ms |
11352 KB |
Output is correct |
71 |
Partially correct |
53 ms |
11352 KB |
Partially correct - number of queries: 8270 |
72 |
Correct |
14 ms |
11348 KB |
Output is correct |
73 |
Partially correct |
61 ms |
11352 KB |
Partially correct - number of queries: 8159 |
74 |
Partially correct |
59 ms |
11392 KB |
Partially correct - number of queries: 8219 |
75 |
Correct |
12 ms |
11352 KB |
Output is correct |
76 |
Partially correct |
50 ms |
11352 KB |
Partially correct - number of queries: 7113 |
77 |
Partially correct |
51 ms |
11348 KB |
Partially correct - number of queries: 7051 |
78 |
Correct |
14 ms |
11352 KB |
Output is correct |
79 |
Correct |
31 ms |
11352 KB |
Output is correct |
80 |
Partially correct |
53 ms |
11352 KB |
Partially correct - number of queries: 8409 |
81 |
Partially correct |
62 ms |
11352 KB |
Partially correct - number of queries: 8420 |
82 |
Partially correct |
70 ms |
11352 KB |
Partially correct - number of queries: 8353 |
83 |
Correct |
12 ms |
11352 KB |
Output is correct |
84 |
Partially correct |
58 ms |
11396 KB |
Partially correct - number of queries: 6970 |
85 |
Partially correct |
60 ms |
11352 KB |
Partially correct - number of queries: 8433 |
86 |
Correct |
12 ms |
11352 KB |
Output is correct |
87 |
Correct |
13 ms |
11352 KB |
Output is correct |
88 |
Correct |
11 ms |
11352 KB |
Output is correct |
89 |
Correct |
12 ms |
11348 KB |
Output is correct |
90 |
Correct |
10 ms |
11352 KB |
Output is correct |
91 |
Correct |
12 ms |
11352 KB |
Output is correct |
92 |
Correct |
10 ms |
11244 KB |
Output is correct |
93 |
Correct |
15 ms |
11352 KB |
Output is correct |
94 |
Correct |
17 ms |
11352 KB |
Output is correct |
95 |
Correct |
13 ms |
11352 KB |
Output is correct |
96 |
Correct |
13 ms |
11352 KB |
Output is correct |
97 |
Correct |
12 ms |
11352 KB |
Output is correct |