#include "gap.h"
#include<algorithm>
using namespace std;
#define MAXN 100005
const long long INF=1e18;
long long findGap(int T, int N)
{
if(T==1){
long long c[MAXN];
long long ans=0;
MinMax(0ll, INF, c, c+N-1);
for(int i=1; i<(N+1)/2; i++) MinMax(c[i-1]+1, c[N-i]-1, c+i, c+N-i-1);
for(int i=0; i<N-1; i++) if(c[i+1]-c[i]>ans) ans=c[i+1]-c[i];
return ans;
}
else{
long long a[MAXN];
long long b[MAXN];
long long ans=0;
long an;
a[0]=-1;
MinMax(0ll, INF, a+1, a+2);
b[0]=a[1]-1;
for(int i=1; i<N; i++){
if(i<=(a[2]-a[1]+1)%(N-1)) b[i]=b[i-1]+(a[2]-a[1])/(N-1)+1;
else b[i]=b[i-1]+(a[2]-a[1]+1)/(N-1);
}
for(int i=0; i<N-1; i++) MinMax(b[i]+1, b[i+1], a+i*2+3, a+i*2+4);
sort(a, a+2*N+1);
an=unique(a, a+2*N+1)-a;
for(int i=1; i<an-1; i++) if(a[i+1]-a[i]>ans) ans=a[i+1]-a[i];
return ans;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
1 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
256 KB |
Output is correct |
9 |
Correct |
2 ms |
256 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
384 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
3 ms |
384 KB |
Output is correct |
14 |
Correct |
2 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
13 ms |
796 KB |
Output is correct |
17 |
Correct |
12 ms |
768 KB |
Output is correct |
18 |
Correct |
12 ms |
768 KB |
Output is correct |
19 |
Correct |
12 ms |
768 KB |
Output is correct |
20 |
Correct |
9 ms |
768 KB |
Output is correct |
21 |
Correct |
52 ms |
1912 KB |
Output is correct |
22 |
Correct |
45 ms |
1912 KB |
Output is correct |
23 |
Correct |
45 ms |
1836 KB |
Output is correct |
24 |
Correct |
46 ms |
1912 KB |
Output is correct |
25 |
Correct |
38 ms |
1912 KB |
Output is correct |
26 |
Correct |
44 ms |
1848 KB |
Output is correct |
27 |
Correct |
44 ms |
1832 KB |
Output is correct |
28 |
Correct |
45 ms |
1928 KB |
Output is correct |
29 |
Correct |
44 ms |
1912 KB |
Output is correct |
30 |
Correct |
33 ms |
1912 KB |
Output is correct |
31 |
Correct |
2 ms |
384 KB |
Output is correct |
32 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
3 ms |
384 KB |
Output is correct |
12 |
Correct |
3 ms |
384 KB |
Output is correct |
13 |
Correct |
3 ms |
384 KB |
Output is correct |
14 |
Correct |
3 ms |
384 KB |
Output is correct |
15 |
Correct |
3 ms |
384 KB |
Output is correct |
16 |
Correct |
18 ms |
1152 KB |
Output is correct |
17 |
Correct |
20 ms |
1152 KB |
Output is correct |
18 |
Correct |
19 ms |
1152 KB |
Output is correct |
19 |
Correct |
18 ms |
1152 KB |
Output is correct |
20 |
Correct |
10 ms |
1152 KB |
Output is correct |
21 |
Correct |
70 ms |
2680 KB |
Output is correct |
22 |
Correct |
69 ms |
2680 KB |
Output is correct |
23 |
Correct |
67 ms |
2684 KB |
Output is correct |
24 |
Correct |
69 ms |
2808 KB |
Output is correct |
25 |
Correct |
61 ms |
2808 KB |
Output is correct |
26 |
Correct |
69 ms |
2680 KB |
Output is correct |
27 |
Correct |
69 ms |
2592 KB |
Output is correct |
28 |
Correct |
68 ms |
2808 KB |
Output is correct |
29 |
Correct |
69 ms |
2660 KB |
Output is correct |
30 |
Correct |
37 ms |
2680 KB |
Output is correct |
31 |
Correct |
2 ms |
384 KB |
Output is correct |
32 |
Correct |
2 ms |
384 KB |
Output is correct |