Submission #300095

# Submission time Handle Problem Language Result Execution time Memory
300095 2020-09-16T15:04:32 Z a_player Gap (APIO16_gap) C++14
100 / 100
78 ms 1976 KB
```#include "gap.h"
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
long long findGap(int T, int N){
if(T==1){
ll mx, mn;
vector<ll> a(N);
MinMax(0,2e18,&mn,&mx);
a[0]=mn;
a[N-1]=mx;
for(int i=1;i<(N+1)/2;i++){
ll mnn,mxx;
MinMax(mn+1,mx-1,&mnn,&mxx);
if(mnn==-1)break;
a[i]=mnn;
a[N-i-1]=mxx;
mn=mnn;
mx=mxx;
}
ll ans=0;
for(int i=1;i<N;i++)ans=max(ans,a[i]-a[i-1]);
return ans;
}
ll mn,mx;
MinMax(0,2e18,&mn,&mx);
ll d=(mx-mn+N-1)/N;
ll a=mn+1;
ll b=mn+d;
ll l=mn;
ll ans=0;
for(int i=0;i<N;i++){
if(b>=mx)b=mx-1;
if(a>b)break;
ll mnn,mxx;
MinMax(a,b,&mnn,&mxx);
if(mnn!=-1){
ans=max(ans,mnn-l);
l=mxx;
}
a+=d;
b+=d;
}
ans=max(ans,mx-l);
return ans;
}
```

# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 13 ms 768 KB Output is correct
17 Correct 15 ms 768 KB Output is correct
18 Correct 13 ms 768 KB Output is correct
19 Correct 13 ms 768 KB Output is correct
20 Correct 9 ms 768 KB Output is correct
21 Correct 56 ms 1956 KB Output is correct
22 Correct 54 ms 1912 KB Output is correct
23 Correct 54 ms 1912 KB Output is correct
24 Correct 55 ms 1912 KB Output is correct
25 Correct 49 ms 1912 KB Output is correct
26 Correct 53 ms 1976 KB Output is correct
27 Correct 54 ms 1912 KB Output is correct
28 Correct 51 ms 1912 KB Output is correct
29 Correct 58 ms 1912 KB Output is correct
30 Correct 39 ms 1876 KB Output is correct
31 Correct 0 ms 384 KB Output is correct
32 Correct 0 ms 384 KB Output is correct

# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 16 ms 512 KB Output is correct
17 Correct 17 ms 512 KB Output is correct
18 Correct 19 ms 512 KB Output is correct
19 Correct 18 ms 512 KB Output is correct
20 Correct 11 ms 512 KB Output is correct
21 Correct 67 ms 1144 KB Output is correct
22 Correct 70 ms 1272 KB Output is correct
23 Correct 73 ms 1144 KB Output is correct
24 Correct 69 ms 1048 KB Output is correct
25 Correct 61 ms 1272 KB Output is correct
26 Correct 70 ms 1060 KB Output is correct
27 Correct 68 ms 1144 KB Output is correct
28 Correct 78 ms 1128 KB Output is correct
29 Correct 70 ms 1092 KB Output is correct
30 Correct 37 ms 1152 KB Output is correct
31 Correct 0 ms 384 KB Output is correct
32 Correct 0 ms 384 KB Output is correct