# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
876561 |
2023-11-22T00:08:35 Z |
AlphaMale06 |
Gap (APIO16_gap) |
C++14 |
|
37 ms |
3876 KB |
#include<bits/stdc++.h>
#include "gap.h"
using namespace std;
using ll=long long;
long long findGap(int subt, int n){
if(subt==1){
ll mn=0;
ll mx=1e18;
ll a[n];
for(int i=0; i< (n+1)/2; i++){
MinMax(mn, mx, &mn, &mx);
a[i]=mn;
a[n-i-1]=mx;
mn++;
mx--;
}
ll ans=0;
for(int i=1; i<n; i++){
ans=max(ans, a[i]-a[i-1]);
}
return ans;
}
else{
ll mn=0; ll mx=1e18;
MinMax(mn, mx, &mn, &mx);
ll mngap=(mx-mn+n-2)/(n-1)+1;
ll l=mn+1;
while(true){
ll qmn=l;
if(mx-qmn+1<mngap)break;
ll qmx=l+mngap-1;
MinMax(qmn, qmx, &qmn, &qmx);
if(qmx==-1){
while(true){
ll posgp=2*mngap;
ll qmn2=l;
ll qmx2=l+posgp-1;
if(qmx2>=mx){
qmx2=mx-1;
MinMax(qmn2, qmx2, &qmn2, &qmx2);
if(qmx2==-1){
return mx-l+1;
}
else{
return qmn2-l+1;
}
}
MinMax(qmn2, qmx2, &qmn2, &qmx2);
if(qmx2==-1){
mngap=posgp+2;
}
else{
mngap=qmn2-l+2;
l=qmx2+1;
break;
}
}
}
else{
if(qmx==qmn && qmx==l+mngap-1){
mngap++;
}
l=qmx+1;
}
}
return mngap-1;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
2392 KB |
Output is correct |
3 |
Correct |
0 ms |
2392 KB |
Output is correct |
4 |
Correct |
1 ms |
2392 KB |
Output is correct |
5 |
Correct |
0 ms |
2388 KB |
Output is correct |
6 |
Correct |
0 ms |
2392 KB |
Output is correct |
7 |
Correct |
1 ms |
2392 KB |
Output is correct |
8 |
Correct |
0 ms |
2392 KB |
Output is correct |
9 |
Correct |
1 ms |
2392 KB |
Output is correct |
10 |
Correct |
1 ms |
2392 KB |
Output is correct |
11 |
Correct |
1 ms |
2392 KB |
Output is correct |
12 |
Correct |
1 ms |
2392 KB |
Output is correct |
13 |
Correct |
1 ms |
2392 KB |
Output is correct |
14 |
Correct |
1 ms |
2392 KB |
Output is correct |
15 |
Correct |
1 ms |
2392 KB |
Output is correct |
16 |
Correct |
7 ms |
2588 KB |
Output is correct |
17 |
Correct |
7 ms |
2584 KB |
Output is correct |
18 |
Correct |
7 ms |
2588 KB |
Output is correct |
19 |
Correct |
8 ms |
2584 KB |
Output is correct |
20 |
Correct |
6 ms |
2576 KB |
Output is correct |
21 |
Correct |
28 ms |
3640 KB |
Output is correct |
22 |
Correct |
28 ms |
3628 KB |
Output is correct |
23 |
Correct |
29 ms |
3628 KB |
Output is correct |
24 |
Correct |
29 ms |
3876 KB |
Output is correct |
25 |
Correct |
26 ms |
3624 KB |
Output is correct |
26 |
Correct |
28 ms |
3624 KB |
Output is correct |
27 |
Correct |
28 ms |
3624 KB |
Output is correct |
28 |
Correct |
28 ms |
3624 KB |
Output is correct |
29 |
Correct |
30 ms |
3636 KB |
Output is correct |
30 |
Correct |
23 ms |
3620 KB |
Output is correct |
31 |
Correct |
1 ms |
2392 KB |
Output is correct |
32 |
Correct |
0 ms |
2392 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2392 KB |
Output is correct |
2 |
Correct |
0 ms |
2392 KB |
Output is correct |
3 |
Correct |
1 ms |
2392 KB |
Output is correct |
4 |
Correct |
0 ms |
2392 KB |
Output is correct |
5 |
Correct |
0 ms |
2392 KB |
Output is correct |
6 |
Correct |
1 ms |
2392 KB |
Output is correct |
7 |
Correct |
1 ms |
2464 KB |
Output is correct |
8 |
Correct |
0 ms |
2392 KB |
Output is correct |
9 |
Correct |
2 ms |
2392 KB |
Output is correct |
10 |
Correct |
0 ms |
2392 KB |
Output is correct |
11 |
Correct |
1 ms |
2392 KB |
Output is correct |
12 |
Correct |
1 ms |
2392 KB |
Output is correct |
13 |
Correct |
1 ms |
2548 KB |
Output is correct |
14 |
Correct |
1 ms |
2392 KB |
Output is correct |
15 |
Correct |
1 ms |
2392 KB |
Output is correct |
16 |
Correct |
5 ms |
2752 KB |
Output is correct |
17 |
Correct |
5 ms |
2580 KB |
Output is correct |
18 |
Correct |
5 ms |
2752 KB |
Output is correct |
19 |
Correct |
5 ms |
2584 KB |
Output is correct |
20 |
Correct |
2 ms |
2568 KB |
Output is correct |
21 |
Correct |
17 ms |
2860 KB |
Output is correct |
22 |
Correct |
18 ms |
2864 KB |
Output is correct |
23 |
Correct |
18 ms |
2856 KB |
Output is correct |
24 |
Correct |
17 ms |
2868 KB |
Output is correct |
25 |
Correct |
37 ms |
2856 KB |
Output is correct |
26 |
Correct |
18 ms |
2868 KB |
Output is correct |
27 |
Correct |
18 ms |
2864 KB |
Output is correct |
28 |
Correct |
21 ms |
2820 KB |
Output is correct |
29 |
Correct |
18 ms |
2856 KB |
Output is correct |
30 |
Correct |
9 ms |
2852 KB |
Output is correct |
31 |
Correct |
1 ms |
2392 KB |
Output is correct |
32 |
Correct |
0 ms |
2392 KB |
Output is correct |