#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1000000000000000000LL;
ll a[100005];
long long findGap(int T, int N){
if(T == 1){
int l = 1, r = N;
a[N+1] = INF+1;
while(l <= r){
MinMax(a[l-1]+1, a[r+1]-1, &a[l], &a[r]);
l++;
r--;
}
ll res = 0;
for(int i=2; i<=N; i++) res = max(res, a[i]-a[i-1]);
return res;
}
ll mn, mx;
MinMax(1, INF, &mn, &mx);
ll block = (mx-mn+N-2)/(N-1);
ll res = block;
ll posl = mn;
ll i;
for(i=mn; i+block+1 <= mx; i += block+1){
ll a, b;
MinMax(i, i+block+1, &a, &b);
if(a == -1) continue;
res = max(res, a-posl);
posl = b;
}
ll a, b;
MinMax(i, mx, &a, &b);
if(a != -1) res = max(res, a-posl);
return res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
0 ms |
364 KB |
Output is correct |
4 |
Correct |
0 ms |
364 KB |
Output is correct |
5 |
Correct |
0 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
0 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
492 KB |
Output is correct |
10 |
Correct |
0 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
11 ms |
748 KB |
Output is correct |
17 |
Correct |
11 ms |
748 KB |
Output is correct |
18 |
Correct |
11 ms |
748 KB |
Output is correct |
19 |
Correct |
11 ms |
748 KB |
Output is correct |
20 |
Correct |
8 ms |
748 KB |
Output is correct |
21 |
Correct |
44 ms |
1900 KB |
Output is correct |
22 |
Correct |
42 ms |
1900 KB |
Output is correct |
23 |
Correct |
43 ms |
1900 KB |
Output is correct |
24 |
Correct |
43 ms |
1912 KB |
Output is correct |
25 |
Correct |
38 ms |
1892 KB |
Output is correct |
26 |
Correct |
46 ms |
1900 KB |
Output is correct |
27 |
Correct |
49 ms |
1900 KB |
Output is correct |
28 |
Correct |
42 ms |
1900 KB |
Output is correct |
29 |
Correct |
44 ms |
1900 KB |
Output is correct |
30 |
Correct |
35 ms |
1900 KB |
Output is correct |
31 |
Correct |
1 ms |
364 KB |
Output is correct |
32 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
0 ms |
364 KB |
Output is correct |
4 |
Correct |
0 ms |
364 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
0 ms |
364 KB |
Output is correct |
8 |
Correct |
0 ms |
364 KB |
Output is correct |
9 |
Correct |
0 ms |
364 KB |
Output is correct |
10 |
Correct |
0 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
2 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
14 ms |
492 KB |
Output is correct |
17 |
Correct |
17 ms |
492 KB |
Output is correct |
18 |
Correct |
16 ms |
492 KB |
Output is correct |
19 |
Correct |
14 ms |
492 KB |
Output is correct |
20 |
Correct |
8 ms |
492 KB |
Output is correct |
21 |
Correct |
59 ms |
1144 KB |
Output is correct |
22 |
Correct |
59 ms |
1132 KB |
Output is correct |
23 |
Correct |
61 ms |
1132 KB |
Output is correct |
24 |
Correct |
60 ms |
1132 KB |
Output is correct |
25 |
Correct |
55 ms |
1132 KB |
Output is correct |
26 |
Correct |
62 ms |
1132 KB |
Output is correct |
27 |
Correct |
59 ms |
1132 KB |
Output is correct |
28 |
Correct |
59 ms |
1416 KB |
Output is correct |
29 |
Correct |
60 ms |
1260 KB |
Output is correct |
30 |
Correct |
32 ms |
1132 KB |
Output is correct |
31 |
Correct |
1 ms |
364 KB |
Output is correct |
32 |
Correct |
1 ms |
364 KB |
Output is correct |