#include <iostream>
#include <algorithm>
#include "gap.h"
using namespace std;
long long all[100005];
long long findGap(int T,int N)
{
long long a,b,l=0,r=N-1,x=0,y=1000000000000000000 ,ans=0,c,d,t,i;
if(T==2)
{
MinMax(x,y,&a,&b);
x=(b-a)/(N-1)+1;
t=a;
for(;a<=b;a+=x,a++)
{
l=a;
r=min(b,a+x);
MinMax(l,r,&c,&d);
ans=max(ans,d-c);
if(c!=-1)
{
ans=max(ans,c-t);
t=d;
}
}
}
else
{
while(l<=r)
{
MinMax(x,y,&a,&b);
all[l]=a;
all[r]=b;
x=a+1;
y=b-1;
l++;
r--;
}
for(i=1;i<N;i++) ans=max(ans,all[i]-all[i-1]);
}
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 |
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 |
3 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 |
2 ms |
384 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
2 ms |
384 KB |
Output is correct |
14 |
Correct |
3 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
19 ms |
1152 KB |
Output is correct |
17 |
Correct |
14 ms |
1152 KB |
Output is correct |
18 |
Correct |
19 ms |
1228 KB |
Output is correct |
19 |
Correct |
15 ms |
1152 KB |
Output is correct |
20 |
Correct |
15 ms |
896 KB |
Output is correct |
21 |
Correct |
50 ms |
3648 KB |
Output is correct |
22 |
Correct |
52 ms |
3676 KB |
Output is correct |
23 |
Correct |
60 ms |
3704 KB |
Output is correct |
24 |
Correct |
53 ms |
3704 KB |
Output is correct |
25 |
Correct |
43 ms |
3164 KB |
Output is correct |
26 |
Correct |
49 ms |
3832 KB |
Output is correct |
27 |
Correct |
54 ms |
3704 KB |
Output is correct |
28 |
Correct |
55 ms |
3704 KB |
Output is correct |
29 |
Correct |
51 ms |
3704 KB |
Output is correct |
30 |
Correct |
34 ms |
2552 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 |
2 ms |
304 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
3 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 |
2 ms |
384 KB |
Output is correct |
12 |
Correct |
3 ms |
384 KB |
Output is correct |
13 |
Correct |
2 ms |
384 KB |
Output is correct |
14 |
Correct |
3 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
16 ms |
1024 KB |
Output is correct |
17 |
Correct |
18 ms |
1024 KB |
Output is correct |
18 |
Correct |
18 ms |
896 KB |
Output is correct |
19 |
Correct |
22 ms |
1016 KB |
Output is correct |
20 |
Correct |
13 ms |
644 KB |
Output is correct |
21 |
Correct |
64 ms |
2936 KB |
Output is correct |
22 |
Correct |
62 ms |
2936 KB |
Output is correct |
23 |
Correct |
91 ms |
3064 KB |
Output is correct |
24 |
Correct |
63 ms |
2936 KB |
Output is correct |
25 |
Correct |
60 ms |
2304 KB |
Output is correct |
26 |
Correct |
64 ms |
3008 KB |
Output is correct |
27 |
Correct |
61 ms |
2936 KB |
Output is correct |
28 |
Correct |
62 ms |
2936 KB |
Output is correct |
29 |
Correct |
65 ms |
2936 KB |
Output is correct |
30 |
Correct |
31 ms |
1792 KB |
Output is correct |
31 |
Correct |
2 ms |
384 KB |
Output is correct |
32 |
Correct |
2 ms |
384 KB |
Output is correct |