#include "bits/stdc++.h"
#include "gap.h"
using namespace std;
long long findGap(int T, int N){
if(N <= 8 || T == 1){
vector <long long> A(N);
MinMax(0 ,1e18 ,&A[0] ,&A[N-1]);
for(int i=1; i<(N+1)/2; i++)
MinMax(A[i-1]+1 ,A[N-i]-1 ,&A[i] ,&A[N-i-1]);
long long ret = 1;
for(int i=1; i<N; i++)
ret = max(ret ,A[i]-A[i-1]);
return ret;
}
long long mx_dist = 1 ,s ,t;
MinMax(0 ,1e18 ,&s ,&t);
long long mn = s ,mx = t ,lst = s;
long long d = (mx-mn)/(N-1) ,p = (mx-mn)%(N-1);
vector <long long> rngs(N); rngs[0] = mn+1;
for(int i=1; i<N; i++)
rngs[i] = rngs[i-1] + d + (i < p);
for(int i=0; i<N-1; i++){
MinMax(rngs[i] ,rngs[i+1]-1 ,&s ,&t);
if(s != -1)
mx_dist = max(mx_dist ,s-lst) ,lst = t;
}
return max(mx-lst ,mx_dist);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
256 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
4 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
384 KB |
Output is correct |
6 |
Correct |
4 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
4 ms |
384 KB |
Output is correct |
9 |
Correct |
4 ms |
384 KB |
Output is correct |
10 |
Correct |
4 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
16 |
Correct |
17 ms |
768 KB |
Output is correct |
17 |
Correct |
16 ms |
768 KB |
Output is correct |
18 |
Correct |
18 ms |
740 KB |
Output is correct |
19 |
Correct |
19 ms |
768 KB |
Output is correct |
20 |
Correct |
13 ms |
768 KB |
Output is correct |
21 |
Correct |
54 ms |
1888 KB |
Output is correct |
22 |
Correct |
54 ms |
1912 KB |
Output is correct |
23 |
Correct |
56 ms |
1968 KB |
Output is correct |
24 |
Correct |
54 ms |
1912 KB |
Output is correct |
25 |
Correct |
48 ms |
1912 KB |
Output is correct |
26 |
Correct |
54 ms |
1912 KB |
Output is correct |
27 |
Correct |
56 ms |
1912 KB |
Output is correct |
28 |
Correct |
53 ms |
1912 KB |
Output is correct |
29 |
Correct |
53 ms |
1948 KB |
Output is correct |
30 |
Correct |
46 ms |
1912 KB |
Output is correct |
31 |
Correct |
4 ms |
384 KB |
Output is correct |
32 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
360 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
4 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
384 KB |
Output is correct |
6 |
Correct |
4 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
384 KB |
Output is correct |
8 |
Correct |
4 ms |
384 KB |
Output is correct |
9 |
Correct |
4 ms |
384 KB |
Output is correct |
10 |
Correct |
4 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
16 |
Correct |
20 ms |
768 KB |
Output is correct |
17 |
Correct |
20 ms |
768 KB |
Output is correct |
18 |
Correct |
23 ms |
768 KB |
Output is correct |
19 |
Correct |
20 ms |
768 KB |
Output is correct |
20 |
Correct |
12 ms |
768 KB |
Output is correct |
21 |
Correct |
71 ms |
1912 KB |
Output is correct |
22 |
Correct |
73 ms |
1912 KB |
Output is correct |
23 |
Correct |
74 ms |
1916 KB |
Output is correct |
24 |
Correct |
72 ms |
1912 KB |
Output is correct |
25 |
Correct |
70 ms |
1912 KB |
Output is correct |
26 |
Correct |
81 ms |
1940 KB |
Output is correct |
27 |
Correct |
80 ms |
1912 KB |
Output is correct |
28 |
Correct |
70 ms |
1912 KB |
Output is correct |
29 |
Correct |
71 ms |
1912 KB |
Output is correct |
30 |
Correct |
45 ms |
1896 KB |
Output is correct |
31 |
Correct |
4 ms |
384 KB |
Output is correct |
32 |
Correct |
4 ms |
384 KB |
Output is correct |