#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
long long findGap(int T, int N)
{
long long a[N],mn,mx,mn2,mx2,lo=0,hi=1e18,res=0;
if (T==1){
for (long long i=0;i<N&&i<=N-i-1;i++){
MinMax(lo,hi,&a[i],&a[N-i-1]);
lo=a[i]+1;
hi=a[N-i-1]-1;
}
for (long long i=0;i<N-1;i++)
res=max(res,a[i+1]-a[i]);
return res;
}
MinMax(lo,hi,&mn,&mx);
if (N==2){
return mx-mn;
}
long long cur=mn,h=(mx-mn+N-2)/(N-1);
for (long long i=mn;i<=mx;i+=h+1){
MinMax(i,i+h,&mn2,&mx2);
if (mn2==-1)
continue;
res=max(res,mn2-cur);
cur=mx2;
}
return res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
0 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
1 ms |
208 KB |
Output is correct |
9 |
Correct |
1 ms |
208 KB |
Output is correct |
10 |
Correct |
0 ms |
208 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
10 ms |
592 KB |
Output is correct |
17 |
Correct |
9 ms |
708 KB |
Output is correct |
18 |
Correct |
10 ms |
592 KB |
Output is correct |
19 |
Correct |
12 ms |
680 KB |
Output is correct |
20 |
Correct |
8 ms |
708 KB |
Output is correct |
21 |
Correct |
40 ms |
1816 KB |
Output is correct |
22 |
Correct |
36 ms |
1772 KB |
Output is correct |
23 |
Correct |
38 ms |
1768 KB |
Output is correct |
24 |
Correct |
41 ms |
1820 KB |
Output is correct |
25 |
Correct |
34 ms |
1828 KB |
Output is correct |
26 |
Correct |
37 ms |
1804 KB |
Output is correct |
27 |
Correct |
37 ms |
1864 KB |
Output is correct |
28 |
Correct |
44 ms |
1808 KB |
Output is correct |
29 |
Correct |
43 ms |
1860 KB |
Output is correct |
30 |
Correct |
31 ms |
1832 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
0 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
0 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
1 ms |
208 KB |
Output is correct |
9 |
Correct |
0 ms |
208 KB |
Output is correct |
10 |
Correct |
0 ms |
208 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
14 ms |
712 KB |
Output is correct |
17 |
Correct |
13 ms |
592 KB |
Output is correct |
18 |
Correct |
13 ms |
592 KB |
Output is correct |
19 |
Correct |
12 ms |
592 KB |
Output is correct |
20 |
Correct |
7 ms |
624 KB |
Output is correct |
21 |
Correct |
57 ms |
1820 KB |
Output is correct |
22 |
Correct |
59 ms |
1832 KB |
Output is correct |
23 |
Correct |
55 ms |
1824 KB |
Output is correct |
24 |
Correct |
50 ms |
1856 KB |
Output is correct |
25 |
Correct |
51 ms |
1872 KB |
Output is correct |
26 |
Correct |
57 ms |
1860 KB |
Output is correct |
27 |
Correct |
52 ms |
1824 KB |
Output is correct |
28 |
Correct |
52 ms |
1860 KB |
Output is correct |
29 |
Correct |
58 ms |
1852 KB |
Output is correct |
30 |
Correct |
27 ms |
1872 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
0 ms |
208 KB |
Output is correct |