#include <bits/stdc++.h>
#include "gap.h"
using namespace std;
#define ll long long
ll findGap(int t, int n){
ll mn = 1, mx = 1e18, A[n], lim, lb, ans = 0;
if (t == 1){
for (ll i = 0, j = n - 1; i <= j; i++, j--){
MinMax(mn, mx, &mn, &mx);
A[i] = mn; A[j] = mx;
mn++; mx--;
}
for (ll i = 1; i < n; i++)
ans = max(ans, A[i] - A[i - 1]);
}
else{
MinMax(mn, mx, &mn, &mx);
lb = (mx - mn + n - 2) / (n - 1); lim = mx;
for (ll l = mn + 1, r = l + lb - 1, prvMx = mn; l <= lim; l += lb, r += lb){
MinMax(l, r, &mn, &mx);
ans = max(ans, mn - prvMx);
if (~mx) prvMx = mx;
}
}
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 |
1 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 |
1 ms |
268 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 |
332 KB |
Output is correct |
16 |
Correct |
11 ms |
680 KB |
Output is correct |
17 |
Correct |
11 ms |
584 KB |
Output is correct |
18 |
Correct |
15 ms |
584 KB |
Output is correct |
19 |
Correct |
14 ms |
584 KB |
Output is correct |
20 |
Correct |
9 ms |
584 KB |
Output is correct |
21 |
Correct |
42 ms |
1740 KB |
Output is correct |
22 |
Correct |
43 ms |
1808 KB |
Output is correct |
23 |
Correct |
44 ms |
1832 KB |
Output is correct |
24 |
Correct |
49 ms |
1788 KB |
Output is correct |
25 |
Correct |
47 ms |
1788 KB |
Output is correct |
26 |
Correct |
42 ms |
1728 KB |
Output is correct |
27 |
Correct |
44 ms |
1856 KB |
Output is correct |
28 |
Correct |
44 ms |
1816 KB |
Output is correct |
29 |
Correct |
42 ms |
1732 KB |
Output is correct |
30 |
Correct |
36 ms |
1864 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 |
1 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 |
1 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 |
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 |
16 ms |
656 KB |
Output is correct |
17 |
Correct |
14 ms |
584 KB |
Output is correct |
18 |
Correct |
17 ms |
584 KB |
Output is correct |
19 |
Correct |
14 ms |
676 KB |
Output is correct |
20 |
Correct |
7 ms |
584 KB |
Output is correct |
21 |
Correct |
59 ms |
1860 KB |
Output is correct |
22 |
Correct |
58 ms |
1728 KB |
Output is correct |
23 |
Correct |
61 ms |
1876 KB |
Output is correct |
24 |
Correct |
59 ms |
1816 KB |
Output is correct |
25 |
Correct |
54 ms |
1852 KB |
Output is correct |
26 |
Correct |
58 ms |
1796 KB |
Output is correct |
27 |
Correct |
58 ms |
1868 KB |
Output is correct |
28 |
Correct |
60 ms |
1856 KB |
Output is correct |
29 |
Correct |
65 ms |
1964 KB |
Output is correct |
30 |
Correct |
32 ms |
1872 KB |
Output is correct |
31 |
Correct |
0 ms |
200 KB |
Output is correct |
32 |
Correct |
0 ms |
200 KB |
Output is correct |