#include "gap.h"
#include<bits/stdc++.h>
using namespace std;
const long long K=1000000000000000000LL;
long long a,b,c,d,e,i,j,ii,jj,zx,xc,lef,rig,mid,f[100009],x,pas;
int B,C,D,E;
long long findGap(int T, int NN)
{
a=NN;
if(T==1){
lef=0;rig=K;
zx=0;
while(1){
if(zx*2>=a) break;
MinMax(lef,rig,&c,&d);
if(c==-1){
break;
}
if(c==d){
zx++;
f[zx]=c;
break;
}
zx++;
f[zx]=c;f[a-zx+1]=d;
lef=c+1;rig=d-1;
}
e=0;
for(i=1; i<a; i++){
e=max(e,f[i+1]-f[i]);
}
return e;
}else{
MinMax(0,K,&f[1],&f[a]);
if(a==2){
return f[a]-f[1];
}
x=(f[a]-f[1])/(a-1);
if((f[a]-f[1])%(a-1)!=0) x++;
lef=f[1]+1;
zx=f[1];
pas=0;
while(1){
if(lef>=f[a]) break;
rig=min(f[a]-1,lef+x-1);
MinMax(lef,rig,&c,&d);
if(c!=-1){
pas=max(pas,c-zx);
zx=d;
}
lef=rig+1;
}
pas=max(pas,f[a]-zx);
return pas;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
0 ms |
200 KB |
Output is correct |
5 |
Correct |
1 ms |
200 KB |
Output is correct |
6 |
Correct |
1 ms |
200 KB |
Output is correct |
7 |
Correct |
1 ms |
200 KB |
Output is correct |
8 |
Correct |
0 ms |
200 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
0 ms |
200 KB |
Output is correct |
11 |
Correct |
1 ms |
328 KB |
Output is correct |
12 |
Correct |
1 ms |
328 KB |
Output is correct |
13 |
Correct |
1 ms |
328 KB |
Output is correct |
14 |
Correct |
1 ms |
328 KB |
Output is correct |
15 |
Correct |
1 ms |
328 KB |
Output is correct |
16 |
Correct |
11 ms |
684 KB |
Output is correct |
17 |
Correct |
11 ms |
680 KB |
Output is correct |
18 |
Correct |
11 ms |
712 KB |
Output is correct |
19 |
Correct |
14 ms |
584 KB |
Output is correct |
20 |
Correct |
9 ms |
584 KB |
Output is correct |
21 |
Correct |
52 ms |
1900 KB |
Output is correct |
22 |
Correct |
43 ms |
1824 KB |
Output is correct |
23 |
Correct |
45 ms |
1728 KB |
Output is correct |
24 |
Correct |
44 ms |
1832 KB |
Output is correct |
25 |
Correct |
37 ms |
1800 KB |
Output is correct |
26 |
Correct |
45 ms |
1856 KB |
Output is correct |
27 |
Correct |
49 ms |
1732 KB |
Output is correct |
28 |
Correct |
43 ms |
1792 KB |
Output is correct |
29 |
Correct |
46 ms |
1844 KB |
Output is correct |
30 |
Correct |
37 ms |
1760 KB |
Output is correct |
31 |
Correct |
0 ms |
200 KB |
Output is correct |
32 |
Correct |
1 ms |
200 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
200 KB |
Output is correct |
2 |
Correct |
0 ms |
200 KB |
Output is correct |
3 |
Correct |
1 ms |
200 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
200 KB |
Output is correct |
6 |
Correct |
0 ms |
200 KB |
Output is correct |
7 |
Correct |
0 ms |
200 KB |
Output is correct |
8 |
Correct |
0 ms |
200 KB |
Output is correct |
9 |
Correct |
1 ms |
200 KB |
Output is correct |
10 |
Correct |
1 ms |
200 KB |
Output is correct |
11 |
Correct |
1 ms |
328 KB |
Output is correct |
12 |
Correct |
1 ms |
328 KB |
Output is correct |
13 |
Correct |
2 ms |
328 KB |
Output is correct |
14 |
Correct |
2 ms |
328 KB |
Output is correct |
15 |
Correct |
1 ms |
328 KB |
Output is correct |
16 |
Correct |
18 ms |
456 KB |
Output is correct |
17 |
Correct |
16 ms |
424 KB |
Output is correct |
18 |
Correct |
16 ms |
456 KB |
Output is correct |
19 |
Correct |
15 ms |
456 KB |
Output is correct |
20 |
Correct |
7 ms |
456 KB |
Output is correct |
21 |
Correct |
72 ms |
1024 KB |
Output is correct |
22 |
Correct |
64 ms |
1056 KB |
Output is correct |
23 |
Correct |
61 ms |
972 KB |
Output is correct |
24 |
Correct |
71 ms |
1052 KB |
Output is correct |
25 |
Correct |
55 ms |
1056 KB |
Output is correct |
26 |
Correct |
61 ms |
1084 KB |
Output is correct |
27 |
Correct |
60 ms |
960 KB |
Output is correct |
28 |
Correct |
60 ms |
1052 KB |
Output is correct |
29 |
Correct |
60 ms |
960 KB |
Output is correct |
30 |
Correct |
32 ms |
1056 KB |
Output is correct |
31 |
Correct |
0 ms |
200 KB |
Output is correct |
32 |
Correct |
0 ms |
200 KB |
Output is correct |