#include "gap.h"
#pragma GCC optimize("O3")
//#pragma comment(linker, "/STACK:36777216")
#include<bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
#define all(z) (z).begin(), (z).end()
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 1e2;
pair<ll, ll> ask(ll l, ll r) {
ll nl, nr;
MinMax(l, r, &nl, &nr);
return {nl, nr};
}
long long findGap(int T, int n) {
ll ans = 0;
if (T == 1) {
vector<ll> a(n);
ll l = 0, r = 1e18;
for (int i = 0; i < (n+1)/2; ++i) {
ll nl, nr;
MinMax(l, r, &nl, &nr);
a[i] = nl;
a[n-i-1] = nr;
l = a[i]+1, r = a[n-i-1]-1;
}
for (int i = 1; i < n; ++i) {
ans = max(ans, a[i]-a[i-1]);
}
} else {
auto [x, y] = ask(0, 1e18);
ll B = (y-x)/(n-1), prv = x;
for (ll i = x+1; i <= y; i += B+1) {
auto [a, b] = ask(i, i+B);
if (a != -1) {
ans = max(ans, a-prv);
prv = b;
}
}
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
0 ms |
200 KB |
Output is correct |
4 |
Correct |
0 ms |
200 KB |
Output is correct |
5 |
Correct |
0 ms |
200 KB |
Output is correct |
6 |
Correct |
0 ms |
200 KB |
Output is correct |
7 |
Correct |
0 ms |
200 KB |
Output is correct |
8 |
Correct |
0 ms |
200 KB |
Output is correct |
9 |
Correct |
0 ms |
200 KB |
Output is correct |
10 |
Correct |
0 ms |
200 KB |
Output is correct |
11 |
Correct |
1 ms |
328 KB |
Output is correct |
12 |
Correct |
1 ms |
328 KB |
Output is correct |
13 |
Correct |
1 ms |
328 KB |
Output is correct |
14 |
Correct |
1 ms |
328 KB |
Output is correct |
15 |
Correct |
1 ms |
328 KB |
Output is correct |
16 |
Correct |
9 ms |
672 KB |
Output is correct |
17 |
Correct |
10 ms |
676 KB |
Output is correct |
18 |
Correct |
10 ms |
624 KB |
Output is correct |
19 |
Correct |
9 ms |
712 KB |
Output is correct |
20 |
Correct |
8 ms |
712 KB |
Output is correct |
21 |
Correct |
36 ms |
1776 KB |
Output is correct |
22 |
Correct |
37 ms |
1820 KB |
Output is correct |
23 |
Correct |
36 ms |
1816 KB |
Output is correct |
24 |
Correct |
35 ms |
1820 KB |
Output is correct |
25 |
Correct |
33 ms |
1824 KB |
Output is correct |
26 |
Correct |
42 ms |
1756 KB |
Output is correct |
27 |
Correct |
37 ms |
1816 KB |
Output is correct |
28 |
Correct |
36 ms |
1784 KB |
Output is correct |
29 |
Correct |
36 ms |
1792 KB |
Output is correct |
30 |
Correct |
31 ms |
1860 KB |
Output is correct |
31 |
Correct |
0 ms |
200 KB |
Output is correct |
32 |
Correct |
0 ms |
200 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
0 ms |
200 KB |
Output is correct |
4 |
Correct |
0 ms |
200 KB |
Output is correct |
5 |
Correct |
0 ms |
200 KB |
Output is correct |
6 |
Correct |
0 ms |
200 KB |
Output is correct |
7 |
Correct |
0 ms |
200 KB |
Output is correct |
8 |
Correct |
0 ms |
200 KB |
Output is correct |
9 |
Correct |
1 ms |
200 KB |
Output is correct |
10 |
Correct |
0 ms |
200 KB |
Output is correct |
11 |
Correct |
1 ms |
328 KB |
Output is correct |
12 |
Correct |
1 ms |
200 KB |
Output is correct |
13 |
Correct |
1 ms |
328 KB |
Output is correct |
14 |
Correct |
1 ms |
328 KB |
Output is correct |
15 |
Correct |
1 ms |
328 KB |
Output is correct |
16 |
Correct |
14 ms |
496 KB |
Output is correct |
17 |
Correct |
12 ms |
456 KB |
Output is correct |
18 |
Correct |
12 ms |
424 KB |
Output is correct |
19 |
Correct |
12 ms |
456 KB |
Output is correct |
20 |
Correct |
6 ms |
456 KB |
Output is correct |
21 |
Correct |
50 ms |
1048 KB |
Output is correct |
22 |
Correct |
49 ms |
1080 KB |
Output is correct |
23 |
Correct |
50 ms |
1048 KB |
Output is correct |
24 |
Correct |
51 ms |
1072 KB |
Output is correct |
25 |
Correct |
47 ms |
1072 KB |
Output is correct |
26 |
Correct |
56 ms |
1076 KB |
Output is correct |
27 |
Correct |
50 ms |
960 KB |
Output is correct |
28 |
Correct |
52 ms |
968 KB |
Output is correct |
29 |
Correct |
57 ms |
996 KB |
Output is correct |
30 |
Correct |
28 ms |
960 KB |
Output is correct |
31 |
Correct |
0 ms |
212 KB |
Output is correct |
32 |
Correct |
0 ms |
200 KB |
Output is correct |