#include <bits/stdc++.h>
#include "prize.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define SZ(i) int(i.size())
#define ALL(i) i.begin(), i.end()
#define MEM(i,a) memset(i, (a), sizeof(i))
#define X first
#define Y second
#define eb emplace_back
#define pb push_back
#ifdef tmd
#define debug(...) fprintf(stderr,"#%d-(%s)=",__LINE__,#__VA_ARGS__);_do(__VA_ARGS__);
template<typename T> void _do (T &&x) {cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y) {cerr<<x<<", ";_do(y...);}
#else
#define debug(...)
#endif
map<int, vector<int> > mem;
vector<int> sask (int idx) {
if (mem.count(idx) == 0) {
mem[idx] = ask(idx);
}
return mem[idx];
}
int find_best(int n) {
srand(880301);
int mx = 0;
for (int i=0; i<50; i++) {
vector<int> res = sask(rand() % n);
mx = max(mx, res[0] + res[1]);
}
debug(mx);
for(int i = 0; i < n; i++) {
std::vector<int> res = sask(i);
if(res[0] + res[1] == 0) return i;
if (res[0] + res[1] < mx) continue;
int L = i, R = n;
while (L < R - 1) {
int M = (L + R) >> 1;
vector<int> resM = sask(M);
if (resM[0] + resM[1] == 0) return M;
if (resM == res) {
L = M;
} else {
R = M;
}
}
debug(i, R);
i = R-1;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
368 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
396 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
5 |
Correct |
1 ms |
256 KB |
Output is correct |
6 |
Correct |
1 ms |
256 KB |
Output is correct |
7 |
Correct |
1 ms |
256 KB |
Output is correct |
8 |
Correct |
1 ms |
256 KB |
Output is correct |
9 |
Correct |
2 ms |
256 KB |
Output is correct |
10 |
Correct |
2 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
372 KB |
Output is correct |
3 |
Correct |
1 ms |
360 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
1 ms |
256 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
256 KB |
Output is correct |
9 |
Correct |
1 ms |
256 KB |
Output is correct |
10 |
Correct |
1 ms |
256 KB |
Output is correct |
11 |
Correct |
4 ms |
384 KB |
Output is correct |
12 |
Correct |
2 ms |
360 KB |
Output is correct |
13 |
Correct |
7 ms |
376 KB |
Output is correct |
14 |
Correct |
6 ms |
384 KB |
Output is correct |
15 |
Correct |
14 ms |
512 KB |
Output is correct |
16 |
Partially correct |
85 ms |
1056 KB |
Partially correct - number of queries: 6795 |
17 |
Correct |
1 ms |
360 KB |
Output is correct |
18 |
Partially correct |
53 ms |
1284 KB |
Partially correct - number of queries: 7936 |
19 |
Correct |
2 ms |
256 KB |
Output is correct |
20 |
Correct |
22 ms |
528 KB |
Output is correct |
21 |
Correct |
19 ms |
676 KB |
Output is correct |
22 |
Correct |
7 ms |
376 KB |
Output is correct |
23 |
Correct |
1 ms |
256 KB |
Output is correct |
24 |
Correct |
1 ms |
396 KB |
Output is correct |
25 |
Correct |
53 ms |
916 KB |
Output is correct |
26 |
Correct |
48 ms |
796 KB |
Output is correct |
27 |
Correct |
1 ms |
372 KB |
Output is correct |
28 |
Partially correct |
76 ms |
1172 KB |
Partially correct - number of queries: 7477 |
29 |
Partially correct |
62 ms |
888 KB |
Partially correct - number of queries: 5686 |
30 |
Partially correct |
49 ms |
1216 KB |
Partially correct - number of queries: 7894 |
31 |
Correct |
1 ms |
376 KB |
Output is correct |
32 |
Correct |
6 ms |
376 KB |
Output is correct |
33 |
Correct |
1 ms |
256 KB |
Output is correct |
34 |
Correct |
26 ms |
632 KB |
Output is correct |
35 |
Correct |
3 ms |
384 KB |
Output is correct |
36 |
Correct |
26 ms |
484 KB |
Output is correct |
37 |
Correct |
3 ms |
384 KB |
Output is correct |
38 |
Correct |
1 ms |
364 KB |
Output is correct |
39 |
Correct |
38 ms |
740 KB |
Output is correct |
40 |
Partially correct |
75 ms |
1104 KB |
Partially correct - number of queries: 6779 |
41 |
Correct |
61 ms |
772 KB |
Output is correct |
42 |
Correct |
67 ms |
816 KB |
Output is correct |
43 |
Correct |
42 ms |
748 KB |
Output is correct |
44 |
Correct |
23 ms |
712 KB |
Output is correct |
45 |
Correct |
18 ms |
652 KB |
Output is correct |
46 |
Correct |
1 ms |
388 KB |
Output is correct |
47 |
Correct |
53 ms |
760 KB |
Output is correct |
48 |
Partially correct |
59 ms |
888 KB |
Partially correct - number of queries: 5900 |
49 |
Correct |
10 ms |
360 KB |
Output is correct |
50 |
Partially correct |
119 ms |
1252 KB |
Partially correct - number of queries: 7936 |
51 |
Correct |
49 ms |
740 KB |
Output is correct |
52 |
Correct |
2 ms |
256 KB |
Output is correct |
53 |
Correct |
3 ms |
376 KB |
Output is correct |
54 |
Correct |
47 ms |
760 KB |
Output is correct |
55 |
Correct |
2 ms |
372 KB |
Output is correct |
56 |
Partially correct |
96 ms |
1224 KB |
Partially correct - number of queries: 7935 |
57 |
Partially correct |
79 ms |
928 KB |
Partially correct - number of queries: 5815 |
58 |
Partially correct |
80 ms |
916 KB |
Partially correct - number of queries: 5887 |
59 |
Correct |
43 ms |
932 KB |
Output is correct |
60 |
Correct |
55 ms |
844 KB |
Output is correct |
61 |
Correct |
2 ms |
384 KB |
Output is correct |
62 |
Correct |
1 ms |
256 KB |
Output is correct |
63 |
Correct |
3 ms |
384 KB |
Output is correct |
64 |
Correct |
1 ms |
256 KB |
Output is correct |
65 |
Correct |
2 ms |
256 KB |
Output is correct |
66 |
Correct |
5 ms |
404 KB |
Output is correct |
67 |
Correct |
1 ms |
380 KB |
Output is correct |
68 |
Correct |
8 ms |
428 KB |
Output is correct |
69 |
Correct |
5 ms |
376 KB |
Output is correct |
70 |
Correct |
1 ms |
256 KB |
Output is correct |
71 |
Partially correct |
118 ms |
1144 KB |
Partially correct - number of queries: 7883 |
72 |
Correct |
4 ms |
448 KB |
Output is correct |
73 |
Partially correct |
92 ms |
1216 KB |
Partially correct - number of queries: 7782 |
74 |
Partially correct |
70 ms |
1216 KB |
Partially correct - number of queries: 7827 |
75 |
Correct |
3 ms |
380 KB |
Output is correct |
76 |
Partially correct |
70 ms |
1100 KB |
Partially correct - number of queries: 6699 |
77 |
Partially correct |
86 ms |
1208 KB |
Partially correct - number of queries: 8030 |
78 |
Correct |
8 ms |
384 KB |
Output is correct |
79 |
Correct |
24 ms |
760 KB |
Output is correct |
80 |
Partially correct |
85 ms |
1180 KB |
Partially correct - number of queries: 8045 |
81 |
Partially correct |
110 ms |
1300 KB |
Partially correct - number of queries: 8023 |
82 |
Partially correct |
83 ms |
1196 KB |
Partially correct - number of queries: 7964 |
83 |
Correct |
2 ms |
384 KB |
Output is correct |
84 |
Partially correct |
71 ms |
1076 KB |
Partially correct - number of queries: 6551 |
85 |
Partially correct |
87 ms |
1144 KB |
Partially correct - number of queries: 8015 |
86 |
Correct |
41 ms |
760 KB |
Output is correct |
87 |
Correct |
5 ms |
384 KB |
Output is correct |
88 |
Correct |
31 ms |
608 KB |
Output is correct |
89 |
Correct |
34 ms |
760 KB |
Output is correct |
90 |
Correct |
2 ms |
384 KB |
Output is correct |
91 |
Correct |
37 ms |
760 KB |
Output is correct |
92 |
Correct |
1 ms |
256 KB |
Output is correct |
93 |
Correct |
13 ms |
384 KB |
Output is correct |
94 |
Correct |
9 ms |
384 KB |
Output is correct |
95 |
Correct |
10 ms |
384 KB |
Output is correct |
96 |
Correct |
4 ms |
640 KB |
Output is correct |
97 |
Correct |
1 ms |
384 KB |
Output is correct |