#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define per(i, a, b) for (int i = b - 1; i >= (a); --i)
#define trav(a, x) for (auto &a : x)
#define all(x) x.begin(), x.end()
#define sz(x) x.size()
#define pb push_back
#define umap unordered_map
#define uset unordered_set
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef long long ll;
const int INF = 1000000007;
ll findGap(int t, int n) {
ll ans = 0, lo, hi;
MinMax(0, 1e18, &lo, &hi);
if (t == 1) {
ll arr[n];
arr[0] = lo;
arr[n - 1] = hi;
rep(i, 0, (n - 1) / 2) {
ll lotemp, hitemp;
MinMax(lo + 1, hi - 1, &lotemp, &hitemp);
lo = lotemp;
hi = hitemp;
arr[i + 1] = lo;
arr[n - i - 2] = hi;
}
rep(i, 0, n - 1) ans = max(ans, arr[i + 1] - arr[i]);
} else {
ll gap = (hi - lo + n - 2) / (n - 1), curr = lo, pos = curr,guess=1;
while (curr != hi) {
pos+=gap;
ll next;
MinMax(curr + 1, pos, &lo, &next);
++guess;
if(next!=-1) {
ans = max(ans, lo - curr);
curr = next;
}
}
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
1 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
1 ms |
200 KB |
Output is correct |
5 |
Correct |
0 ms |
200 KB |
Output is correct |
6 |
Correct |
1 ms |
200 KB |
Output is correct |
7 |
Correct |
1 ms |
200 KB |
Output is correct |
8 |
Correct |
1 ms |
200 KB |
Output is correct |
9 |
Correct |
1 ms |
200 KB |
Output is correct |
10 |
Correct |
1 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 |
12 ms |
608 KB |
Output is correct |
17 |
Correct |
13 ms |
672 KB |
Output is correct |
18 |
Correct |
12 ms |
584 KB |
Output is correct |
19 |
Correct |
13 ms |
648 KB |
Output is correct |
20 |
Correct |
10 ms |
644 KB |
Output is correct |
21 |
Correct |
50 ms |
1816 KB |
Output is correct |
22 |
Correct |
52 ms |
1824 KB |
Output is correct |
23 |
Correct |
53 ms |
1856 KB |
Output is correct |
24 |
Correct |
46 ms |
1884 KB |
Output is correct |
25 |
Correct |
40 ms |
1856 KB |
Output is correct |
26 |
Correct |
46 ms |
1728 KB |
Output is correct |
27 |
Correct |
46 ms |
1856 KB |
Output is correct |
28 |
Correct |
46 ms |
1824 KB |
Output is correct |
29 |
Correct |
49 ms |
1852 KB |
Output is correct |
30 |
Correct |
36 ms |
1728 KB |
Output is correct |
31 |
Correct |
1 ms |
200 KB |
Output is correct |
32 |
Correct |
1 ms |
200 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
1 ms |
200 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
200 KB |
Output is correct |
7 |
Correct |
1 ms |
200 KB |
Output is correct |
8 |
Correct |
1 ms |
200 KB |
Output is correct |
9 |
Correct |
1 ms |
200 KB |
Output is correct |
10 |
Correct |
1 ms |
200 KB |
Output is correct |
11 |
Correct |
2 ms |
200 KB |
Output is correct |
12 |
Correct |
1 ms |
328 KB |
Output is correct |
13 |
Correct |
1 ms |
328 KB |
Output is correct |
14 |
Correct |
2 ms |
200 KB |
Output is correct |
15 |
Correct |
2 ms |
328 KB |
Output is correct |
16 |
Correct |
17 ms |
460 KB |
Output is correct |
17 |
Correct |
15 ms |
456 KB |
Output is correct |
18 |
Correct |
15 ms |
456 KB |
Output is correct |
19 |
Correct |
15 ms |
456 KB |
Output is correct |
20 |
Correct |
7 ms |
456 KB |
Output is correct |
21 |
Correct |
62 ms |
1052 KB |
Output is correct |
22 |
Correct |
64 ms |
1056 KB |
Output is correct |
23 |
Correct |
62 ms |
1164 KB |
Output is correct |
24 |
Correct |
68 ms |
1028 KB |
Output is correct |
25 |
Correct |
61 ms |
1076 KB |
Output is correct |
26 |
Correct |
62 ms |
1012 KB |
Output is correct |
27 |
Correct |
62 ms |
1056 KB |
Output is correct |
28 |
Correct |
63 ms |
1048 KB |
Output is correct |
29 |
Correct |
66 ms |
1028 KB |
Output is correct |
30 |
Correct |
33 ms |
968 KB |
Output is correct |
31 |
Correct |
1 ms |
200 KB |
Output is correct |
32 |
Correct |
1 ms |
200 KB |
Output is correct |