#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
using vi = vector<int>;
using tint = long long;
using vl = vector<tint>;
long long findGap(int T, int n)
{
if(T == 1){
vl a(n);
int l = 0, r = n-1;
tint L = 0, R = 1e18;
while(l <= r){
MinMax(L, R, &L, &R);
a[l] = L; a[r] = R;
++L; --R;
++l; --r;
}
tint maxi = 0;
F0R(i, n-1) maxi = max(maxi, a[i+1] - a[i]);
return maxi;
}else{
tint L = 0, R = 1e18;
MinMax(L, R, &L, &R);
tint RR = R;
tint lowerBound = (R - L) / (n - 1);
tint ret = lowerBound;
tint last = L;
for(tint i = L; i <= RR; i += lowerBound+1){
MinMax(i, i+lowerBound, &L, &R);
//cout << i << " " << i+lowerBound << " " << L << " " << R << "\n";
if(L != -1){
ret = max(ret, L - last);
last = R;
}
}
return ret;
}
}
# |
결과 |
실행 시간 |
메모리 |
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 |
256 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 |
712 KB |
Output is correct |
17 |
Correct |
9 ms |
712 KB |
Output is correct |
18 |
Correct |
10 ms |
708 KB |
Output is correct |
19 |
Correct |
9 ms |
672 KB |
Output is correct |
20 |
Correct |
8 ms |
712 KB |
Output is correct |
21 |
Correct |
35 ms |
1816 KB |
Output is correct |
22 |
Correct |
35 ms |
1848 KB |
Output is correct |
23 |
Correct |
39 ms |
1828 KB |
Output is correct |
24 |
Correct |
36 ms |
1800 KB |
Output is correct |
25 |
Correct |
31 ms |
1824 KB |
Output is correct |
26 |
Correct |
36 ms |
1848 KB |
Output is correct |
27 |
Correct |
36 ms |
1788 KB |
Output is correct |
28 |
Correct |
44 ms |
1812 KB |
Output is correct |
29 |
Correct |
37 ms |
1864 KB |
Output is correct |
30 |
Correct |
28 ms |
1856 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 |
0 ms |
200 KB |
Output is correct |
10 |
Correct |
0 ms |
200 KB |
Output is correct |
11 |
Correct |
1 ms |
200 KB |
Output is correct |
12 |
Correct |
1 ms |
328 KB |
Output is correct |
13 |
Correct |
2 ms |
328 KB |
Output is correct |
14 |
Correct |
1 ms |
200 KB |
Output is correct |
15 |
Correct |
1 ms |
328 KB |
Output is correct |
16 |
Correct |
12 ms |
416 KB |
Output is correct |
17 |
Correct |
12 ms |
484 KB |
Output is correct |
18 |
Correct |
12 ms |
456 KB |
Output is correct |
19 |
Correct |
13 ms |
500 KB |
Output is correct |
20 |
Correct |
6 ms |
456 KB |
Output is correct |
21 |
Correct |
51 ms |
968 KB |
Output is correct |
22 |
Correct |
52 ms |
1052 KB |
Output is correct |
23 |
Correct |
52 ms |
972 KB |
Output is correct |
24 |
Correct |
49 ms |
1072 KB |
Output is correct |
25 |
Correct |
44 ms |
1076 KB |
Output is correct |
26 |
Correct |
50 ms |
964 KB |
Output is correct |
27 |
Correct |
48 ms |
1084 KB |
Output is correct |
28 |
Correct |
58 ms |
1180 KB |
Output is correct |
29 |
Correct |
51 ms |
1072 KB |
Output is correct |
30 |
Correct |
27 ms |
1096 KB |
Output is correct |
31 |
Correct |
0 ms |
200 KB |
Output is correct |
32 |
Correct |
0 ms |
200 KB |
Output is correct |