#include "gap.h"
#include <bits/stdc++.h>
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
using namespace std;
typedef long long lld;
lld findGap(int T, int N)
{
if (T == 1){
lld p = 0, q = (lld)1e18 + 1;
vector <lld> arr;
for (;;){
lld mn, mx;
MinMax(p+1, q-1, &mn, &mx);
arr.pb(mn); arr.pb(mx);
if (mn == mx || sz(arr) == N) break;
p = mn, q = mx;
}
sort(all(arr));
lld ans = 0;
for (int i=1;i<sz(arr);i++)
ans = max(ans, arr[i]-arr[i-1]);
return ans;
}else{
lld mn, mx;
MinMax(1, 1e18, &mn, &mx);
if (N == 2) return mx-mn;
lld size = mx-mn-1;
lld s = mn+1, last = mn, ans = 0;
for (int i=0;i<N-1;i++){
lld e = s + size / (N-1) - 1;
if (i < size % (N-1)) e++;
MinMax(s, e, &mn, &mx);
if (mn != -1){
ans = max(ans, mn - last);
last = mx;
}
s = e+1;
}
return max(ans, s - last);
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
288 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 |
1 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 |
316 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 |
900 KB |
Output is correct |
17 |
Correct |
13 ms |
840 KB |
Output is correct |
18 |
Correct |
12 ms |
848 KB |
Output is correct |
19 |
Correct |
13 ms |
840 KB |
Output is correct |
20 |
Correct |
10 ms |
840 KB |
Output is correct |
21 |
Correct |
49 ms |
2192 KB |
Output is correct |
22 |
Correct |
47 ms |
2232 KB |
Output is correct |
23 |
Correct |
48 ms |
2200 KB |
Output is correct |
24 |
Correct |
48 ms |
2196 KB |
Output is correct |
25 |
Correct |
51 ms |
2220 KB |
Output is correct |
26 |
Correct |
55 ms |
2192 KB |
Output is correct |
27 |
Correct |
52 ms |
2232 KB |
Output is correct |
28 |
Correct |
49 ms |
2192 KB |
Output is correct |
29 |
Correct |
48 ms |
2232 KB |
Output is correct |
30 |
Correct |
38 ms |
2132 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 |
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 |
1 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 |
288 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 |
200 KB |
Output is correct |
12 |
Correct |
2 ms |
328 KB |
Output is correct |
13 |
Correct |
1 ms |
200 KB |
Output is correct |
14 |
Correct |
1 ms |
328 KB |
Output is correct |
15 |
Correct |
1 ms |
200 KB |
Output is correct |
16 |
Correct |
14 ms |
504 KB |
Output is correct |
17 |
Correct |
14 ms |
504 KB |
Output is correct |
18 |
Correct |
15 ms |
452 KB |
Output is correct |
19 |
Correct |
14 ms |
508 KB |
Output is correct |
20 |
Correct |
8 ms |
504 KB |
Output is correct |
21 |
Correct |
58 ms |
1052 KB |
Output is correct |
22 |
Correct |
57 ms |
1048 KB |
Output is correct |
23 |
Correct |
58 ms |
1000 KB |
Output is correct |
24 |
Correct |
61 ms |
1132 KB |
Output is correct |
25 |
Correct |
53 ms |
1076 KB |
Output is correct |
26 |
Correct |
58 ms |
1012 KB |
Output is correct |
27 |
Correct |
59 ms |
1068 KB |
Output is correct |
28 |
Correct |
60 ms |
1048 KB |
Output is correct |
29 |
Correct |
68 ms |
1056 KB |
Output is correct |
30 |
Correct |
32 ms |
1064 KB |
Output is correct |
31 |
Correct |
1 ms |
200 KB |
Output is correct |
32 |
Correct |
1 ms |
200 KB |
Output is correct |