#include "prize.h"
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
#define fi first
#define se second
#define left BAO
#define right ANH
#define pb push_back
#define pf push_front
#define mp make_pair
#define ins insert
#define btpc __builtin_popcount
#define btclz __builtin_clz
#define sz(x) (int)(x.size());
#define all(x) x.begin(), x.end()
#define debug(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int d4x[4] = {1, 0, -1, 0}; int d4y[4] = {0, 1, 0, -1};
int d8x[8] = {0, 1, 1, 1, 0, -1, -1, -1};
int d8y[8] = {1, 1, 0, -1, -1, -1, 0, 1};
template<class X, class Y>
bool minimize(X &x, const Y &y) {
if (x > y)
{
x = y;
return true;
}
return false;
}
template<class X, class Y>
bool maximize(X &x, const Y &y) {
if (x < y)
{
x = y;
return true;
}
return false;
}
const int MOD = 1e9 + 7; //998244353
template<class X, class Y>
void add(X &x, const Y &y) {
x = (x + y);
if(x >= MOD) x -= MOD;
}
template<class X, class Y>
void sub(X &x, const Y &y) {
x = (x - y);
if(x < 0) x += MOD;
}
/* Author : Le Ngoc Bao Anh, 12A5, LQD High School for Gifted Student*/
const ll INF = 1e9;
const int N = 1e5 + 10;
int find_best(int n) {
int pos = 0, rr = 0;
vector<int> t;
for(int i = 1; i <= 800; i++) {
int cc = rng() % n;
vector<int> curr = ask(cc);
if(curr[0] + curr[1] > rr) pos = cc, rr = curr[0] + curr[1], t = curr;
}
int p = pos;
int iter = pos + 1;
while(true) {
if(!t[1]) break;
int l = iter;
int r = n - 1;
pos = -1;
while(l <= r) {
int mid = (l + r) >> 1;
vector<int> v = ask(mid);
if(v[0] + v[1] < rr) {
if(!v[0] && !v[1]) return mid;
pos = mid;
r = mid - 1;
continue;
}
if(v[1] < t[1]) {
r = mid - 1;
} else l = mid + 1;
}
if(pos == -1) break;
t[1]--;
iter = pos + 1;
}
iter = p - 1;
while(true) {
int l = 0;
int r = iter;
pos = -1;
if(!t[0]) break;
while(l <= r) {
int mid = (l + r) >> 1;
vector<int> v = ask(mid);
if(v[0] + v[1] < rr) {
if(!v[0] && !v[1]) return mid;
pos = mid;
l = mid + 1;
continue;
}
if(v[0] < t[0]) {
l = mid + 1;
} else r = mid - 1;
}
if(pos == -1) break;
t[0]--;
iter = pos - 1;
}
assert(false);
return -1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
292 KB |
Output is correct |
2 |
Correct |
7 ms |
300 KB |
Output is correct |
3 |
Correct |
4 ms |
292 KB |
Output is correct |
4 |
Correct |
9 ms |
208 KB |
Output is correct |
5 |
Correct |
8 ms |
296 KB |
Output is correct |
6 |
Correct |
7 ms |
208 KB |
Output is correct |
7 |
Correct |
8 ms |
296 KB |
Output is correct |
8 |
Correct |
5 ms |
292 KB |
Output is correct |
9 |
Correct |
5 ms |
292 KB |
Output is correct |
10 |
Correct |
8 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
288 KB |
Output is correct |
2 |
Correct |
10 ms |
296 KB |
Output is correct |
3 |
Correct |
10 ms |
296 KB |
Output is correct |
4 |
Correct |
6 ms |
208 KB |
Output is correct |
5 |
Correct |
6 ms |
296 KB |
Output is correct |
6 |
Correct |
8 ms |
276 KB |
Output is correct |
7 |
Correct |
9 ms |
208 KB |
Output is correct |
8 |
Correct |
5 ms |
208 KB |
Output is correct |
9 |
Correct |
8 ms |
296 KB |
Output is correct |
10 |
Correct |
9 ms |
208 KB |
Output is correct |
11 |
Correct |
11 ms |
296 KB |
Output is correct |
12 |
Correct |
12 ms |
292 KB |
Output is correct |
13 |
Correct |
5 ms |
208 KB |
Output is correct |
14 |
Correct |
9 ms |
208 KB |
Output is correct |
15 |
Partially correct |
48 ms |
208 KB |
Partially correct - number of queries: 5731 |
16 |
Partially correct |
52 ms |
288 KB |
Partially correct - number of queries: 5291 |
17 |
Partially correct |
70 ms |
208 KB |
Partially correct - number of queries: 8198 |
18 |
Correct |
10 ms |
208 KB |
Output is correct |
19 |
Partially correct |
73 ms |
300 KB |
Partially correct - number of queries: 7698 |
20 |
Correct |
8 ms |
208 KB |
Output is correct |
21 |
Partially correct |
62 ms |
292 KB |
Partially correct - number of queries: 5420 |
22 |
Partially correct |
65 ms |
212 KB |
Partially correct - number of queries: 5703 |
23 |
Correct |
11 ms |
296 KB |
Output is correct |
24 |
Correct |
11 ms |
208 KB |
Output is correct |
25 |
Correct |
17 ms |
292 KB |
Output is correct |
26 |
Correct |
44 ms |
296 KB |
Output is correct |
27 |
Correct |
7 ms |
208 KB |
Output is correct |
28 |
Partially correct |
28 ms |
288 KB |
Partially correct - number of queries: 7343 |
29 |
Correct |
27 ms |
208 KB |
Output is correct |
30 |
Partially correct |
46 ms |
292 KB |
Partially correct - number of queries: 7100 |
31 |
Partially correct |
41 ms |
276 KB |
Partially correct - number of queries: 8015 |
32 |
Correct |
11 ms |
276 KB |
Output is correct |
33 |
Correct |
9 ms |
208 KB |
Output is correct |
34 |
Partially correct |
49 ms |
300 KB |
Partially correct - number of queries: 5931 |
35 |
Correct |
8 ms |
292 KB |
Output is correct |
36 |
Correct |
17 ms |
276 KB |
Output is correct |
37 |
Correct |
7 ms |
208 KB |
Output is correct |
38 |
Correct |
9 ms |
208 KB |
Output is correct |
39 |
Correct |
43 ms |
284 KB |
Output is correct |
40 |
Correct |
27 ms |
208 KB |
Output is correct |
41 |
Correct |
10 ms |
208 KB |
Output is correct |
42 |
Correct |
38 ms |
208 KB |
Output is correct |
43 |
Correct |
8 ms |
300 KB |
Output is correct |
44 |
Partially correct |
38 ms |
208 KB |
Partially correct - number of queries: 5383 |
45 |
Correct |
16 ms |
208 KB |
Output is correct |
46 |
Partially correct |
60 ms |
292 KB |
Partially correct - number of queries: 8149 |
47 |
Correct |
11 ms |
208 KB |
Output is correct |
48 |
Correct |
12 ms |
208 KB |
Output is correct |
49 |
Partially correct |
63 ms |
296 KB |
Partially correct - number of queries: 7615 |
50 |
Correct |
14 ms |
296 KB |
Output is correct |
51 |
Correct |
27 ms |
208 KB |
Output is correct |
52 |
Partially correct |
64 ms |
208 KB |
Partially correct - number of queries: 7983 |
53 |
Correct |
7 ms |
208 KB |
Output is correct |
54 |
Partially correct |
41 ms |
208 KB |
Partially correct - number of queries: 5080 |
55 |
Partially correct |
84 ms |
292 KB |
Partially correct - number of queries: 8051 |
56 |
Correct |
13 ms |
292 KB |
Output is correct |
57 |
Correct |
27 ms |
296 KB |
Output is correct |
58 |
Correct |
20 ms |
208 KB |
Output is correct |
59 |
Correct |
30 ms |
296 KB |
Output is correct |
60 |
Correct |
25 ms |
300 KB |
Output is correct |
61 |
Correct |
7 ms |
208 KB |
Output is correct |
62 |
Correct |
9 ms |
208 KB |
Output is correct |
63 |
Correct |
4 ms |
288 KB |
Output is correct |
64 |
Correct |
9 ms |
208 KB |
Output is correct |
65 |
Correct |
10 ms |
208 KB |
Output is correct |
66 |
Correct |
16 ms |
296 KB |
Output is correct |
67 |
Correct |
7 ms |
208 KB |
Output is correct |
68 |
Correct |
3 ms |
300 KB |
Output is correct |
69 |
Correct |
32 ms |
208 KB |
Output is correct |
70 |
Correct |
6 ms |
292 KB |
Output is correct |
71 |
Partially correct |
51 ms |
272 KB |
Partially correct - number of queries: 8220 |
72 |
Correct |
12 ms |
208 KB |
Output is correct |
73 |
Partially correct |
71 ms |
208 KB |
Partially correct - number of queries: 8483 |
74 |
Partially correct |
40 ms |
208 KB |
Partially correct - number of queries: 8151 |
75 |
Correct |
10 ms |
208 KB |
Output is correct |
76 |
Partially correct |
33 ms |
208 KB |
Partially correct - number of queries: 5572 |
77 |
Partially correct |
56 ms |
208 KB |
Partially correct - number of queries: 8229 |
78 |
Correct |
6 ms |
336 KB |
Output is correct |
79 |
Correct |
35 ms |
208 KB |
Output is correct |
80 |
Partially correct |
51 ms |
208 KB |
Partially correct - number of queries: 7932 |
81 |
Partially correct |
29 ms |
336 KB |
Partially correct - number of queries: 7236 |
82 |
Partially correct |
42 ms |
208 KB |
Partially correct - number of queries: 8346 |
83 |
Correct |
8 ms |
208 KB |
Output is correct |
84 |
Partially correct |
51 ms |
208 KB |
Partially correct - number of queries: 6725 |
85 |
Partially correct |
53 ms |
292 KB |
Partially correct - number of queries: 8128 |
86 |
Partially correct |
82 ms |
208 KB |
Partially correct - number of queries: 7002 |
87 |
Correct |
8 ms |
296 KB |
Output is correct |
88 |
Correct |
25 ms |
296 KB |
Output is correct |
89 |
Correct |
23 ms |
208 KB |
Output is correct |
90 |
Correct |
7 ms |
208 KB |
Output is correct |
91 |
Correct |
27 ms |
208 KB |
Output is correct |
92 |
Correct |
39 ms |
296 KB |
Output is correct |
93 |
Partially correct |
67 ms |
208 KB |
Partially correct - number of queries: 8057 |
94 |
Partially correct |
67 ms |
208 KB |
Partially correct - number of queries: 7559 |
95 |
Partially correct |
69 ms |
208 KB |
Partially correct - number of queries: 6600 |
96 |
Partially correct |
57 ms |
208 KB |
Partially correct - number of queries: 7539 |
97 |
Correct |
39 ms |
208 KB |
Output is correct |