# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
745420 |
2023-05-20T03:11:02 Z |
AirCircles |
Gap (APIO16_gap) |
C++17 |
|
54 ms |
1872 KB |
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
//void MinMax(s,t,&mn,&mx)
long long findGap(int TT, int n){
if(TT==1){
//long long s,t,&mn,&mx;
vector<long long>dn(n);
MinMax(0,1000000000000000000LL,&dn[0],&dn[n-1]);
for(int i=1;i<n/2;i++){
MinMax(dn[i-1]+1,dn[n-i]-1,&dn[i],&dn[n-i-1]);
}
if(n%2==1){
MinMax(dn[n/2-1]+1,dn[n/2+1]-1,&dn[n/2],&dn[n/2]);
}
long long mn=0LL;
for(int i=0;i<n-1;i++){
mn=max(mn,dn[i+1]-dn[i]);
}
return mn;
}else{
long long a,b;
MinMax(0,1000000000000000000LL,&a,&b);
long long d=(b-a-1)/(n-1);
long long x=(b-a-1)-d*(n-1);
long long y=n-1-x;
long long ma=0,xx=a,p=a;//pointer
for(int i=0;i<n-1;i++){
long long mn,mx;
if(i<y){
MinMax(p+1,p+d,&mn,&mx);
p+=d;
}else{
MinMax(p+1,p+d+1,&mn,&mx);
p+=d+1;
}
if(mn!=-1){
ma=max(ma,mn-xx);
xx=mx;
}
}
ma=max(ma,b-xx);
return ma;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
272 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 |
0 ms |
208 KB |
Output is correct |
8 |
Correct |
0 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 |
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 |
720 KB |
Output is correct |
17 |
Correct |
9 ms |
636 KB |
Output is correct |
18 |
Correct |
10 ms |
720 KB |
Output is correct |
19 |
Correct |
10 ms |
680 KB |
Output is correct |
20 |
Correct |
7 ms |
720 KB |
Output is correct |
21 |
Correct |
36 ms |
1828 KB |
Output is correct |
22 |
Correct |
43 ms |
1824 KB |
Output is correct |
23 |
Correct |
37 ms |
1756 KB |
Output is correct |
24 |
Correct |
42 ms |
1872 KB |
Output is correct |
25 |
Correct |
37 ms |
1860 KB |
Output is correct |
26 |
Correct |
40 ms |
1824 KB |
Output is correct |
27 |
Correct |
40 ms |
1756 KB |
Output is correct |
28 |
Correct |
38 ms |
1812 KB |
Output is correct |
29 |
Correct |
42 ms |
1812 KB |
Output is correct |
30 |
Correct |
29 ms |
1872 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
0 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 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 |
1 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 |
208 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
208 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
13 ms |
464 KB |
Output is correct |
17 |
Correct |
14 ms |
428 KB |
Output is correct |
18 |
Correct |
13 ms |
424 KB |
Output is correct |
19 |
Correct |
13 ms |
508 KB |
Output is correct |
20 |
Correct |
8 ms |
516 KB |
Output is correct |
21 |
Correct |
50 ms |
1084 KB |
Output is correct |
22 |
Correct |
50 ms |
1080 KB |
Output is correct |
23 |
Correct |
54 ms |
1192 KB |
Output is correct |
24 |
Correct |
53 ms |
1076 KB |
Output is correct |
25 |
Correct |
47 ms |
1084 KB |
Output is correct |
26 |
Correct |
52 ms |
1056 KB |
Output is correct |
27 |
Correct |
52 ms |
1084 KB |
Output is correct |
28 |
Correct |
49 ms |
1088 KB |
Output is correct |
29 |
Correct |
51 ms |
1000 KB |
Output is correct |
30 |
Correct |
29 ms |
1104 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
0 ms |
208 KB |
Output is correct |