# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1111124 |
2024-11-11T14:38:58 Z |
imarn |
Gap (APIO16_gap) |
C++14 |
|
38 ms |
3644 KB |
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define plx pair<ll,int>
#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vvi vector<vi>
#define pp pair<ll,int>
#define ub(x,i) upper_bound(all(x),i)-x.begin()
#include "gap.h"
using namespace std;
long long cal1(int n){
ll a[n];
ll l=0,r=n-1;
ll mn=0,mx=0;
ll tl=0,tr=1e18;
while(l<=r){
MinMax(tl,tr,&a[l],&a[r]);
tl=a[l]+1,tr=a[r]-1;
l++,r--;
}ll rs=0;
for(int i=1;i<n;i++)rs=max(rs,a[i]-a[i-1]);
return rs;
}
ll cal2(int n){
ll mn,mx;
ll tl=0,tr=1e18;
MinMax(tl,tr,&mn,&mx);
ll ans = (mx-mn-1)/(n-1)+1;
ll cl=-1,cr=-1;
ll rl = mn+1,rr=mn+ans;
while(1){
MinMax(rl,rr,&cl,&cr);
if(cl==-1){
rl = rr+1;
rr = rr+ans;
}
else {
ans = max(ans,cl-mn);
mn=cr;
rl=rr+1;
rr=rr+ans;
if(cr==mx)break;
}
}return ans;
}
long long findGap(int T, int N)
{
if(T==1)return cal1(N);
else return cal2(N);
}
/*int main(){m=5;
b[0]=2;
b[1]=3;
b[2]=6;
b[3]=500;
b[4]=10000;
cout<<findGap(2,5);
}*/
Compilation message
gap.cpp: In function 'long long int cal1(int)':
gap.cpp:19:8: warning: unused variable 'mn' [-Wunused-variable]
19 | ll mn=0,mx=0;
| ^~
gap.cpp:19:13: warning: unused variable 'mx' [-Wunused-variable]
19 | ll mn=0,mx=0;
| ^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
2384 KB |
Output is correct |
3 |
Correct |
1 ms |
2556 KB |
Output is correct |
4 |
Correct |
1 ms |
2384 KB |
Output is correct |
5 |
Correct |
1 ms |
2384 KB |
Output is correct |
6 |
Correct |
1 ms |
2384 KB |
Output is correct |
7 |
Correct |
1 ms |
2384 KB |
Output is correct |
8 |
Correct |
1 ms |
2384 KB |
Output is correct |
9 |
Correct |
1 ms |
2556 KB |
Output is correct |
10 |
Correct |
1 ms |
2384 KB |
Output is correct |
11 |
Correct |
1 ms |
2384 KB |
Output is correct |
12 |
Correct |
1 ms |
2384 KB |
Output is correct |
13 |
Correct |
1 ms |
2384 KB |
Output is correct |
14 |
Correct |
1 ms |
2384 KB |
Output is correct |
15 |
Correct |
1 ms |
2384 KB |
Output is correct |
16 |
Correct |
8 ms |
2640 KB |
Output is correct |
17 |
Correct |
7 ms |
2640 KB |
Output is correct |
18 |
Correct |
7 ms |
2752 KB |
Output is correct |
19 |
Correct |
7 ms |
2640 KB |
Output is correct |
20 |
Correct |
6 ms |
2640 KB |
Output is correct |
21 |
Correct |
38 ms |
3408 KB |
Output is correct |
22 |
Correct |
29 ms |
3408 KB |
Output is correct |
23 |
Correct |
28 ms |
3408 KB |
Output is correct |
24 |
Correct |
28 ms |
3408 KB |
Output is correct |
25 |
Correct |
25 ms |
3572 KB |
Output is correct |
26 |
Correct |
28 ms |
3408 KB |
Output is correct |
27 |
Correct |
28 ms |
3644 KB |
Output is correct |
28 |
Correct |
28 ms |
3408 KB |
Output is correct |
29 |
Correct |
30 ms |
3416 KB |
Output is correct |
30 |
Correct |
28 ms |
3408 KB |
Output is correct |
31 |
Correct |
1 ms |
2384 KB |
Output is correct |
32 |
Correct |
1 ms |
2384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2384 KB |
Output is correct |
2 |
Correct |
1 ms |
2384 KB |
Output is correct |
3 |
Correct |
1 ms |
2384 KB |
Output is correct |
4 |
Correct |
1 ms |
2384 KB |
Output is correct |
5 |
Correct |
1 ms |
2384 KB |
Output is correct |
6 |
Correct |
1 ms |
2384 KB |
Output is correct |
7 |
Correct |
1 ms |
2384 KB |
Output is correct |
8 |
Correct |
1 ms |
2384 KB |
Output is correct |
9 |
Correct |
1 ms |
2384 KB |
Output is correct |
10 |
Correct |
1 ms |
2384 KB |
Output is correct |
11 |
Correct |
1 ms |
2384 KB |
Output is correct |
12 |
Correct |
1 ms |
2384 KB |
Output is correct |
13 |
Correct |
2 ms |
2384 KB |
Output is correct |
14 |
Correct |
1 ms |
2384 KB |
Output is correct |
15 |
Correct |
2 ms |
2384 KB |
Output is correct |
16 |
Correct |
6 ms |
2536 KB |
Output is correct |
17 |
Correct |
5 ms |
2384 KB |
Output is correct |
18 |
Correct |
7 ms |
2384 KB |
Output is correct |
19 |
Correct |
9 ms |
2528 KB |
Output is correct |
20 |
Correct |
4 ms |
2396 KB |
Output is correct |
21 |
Correct |
32 ms |
2848 KB |
Output is correct |
22 |
Correct |
20 ms |
2640 KB |
Output is correct |
23 |
Correct |
20 ms |
2640 KB |
Output is correct |
24 |
Correct |
20 ms |
2640 KB |
Output is correct |
25 |
Correct |
34 ms |
2640 KB |
Output is correct |
26 |
Correct |
27 ms |
2640 KB |
Output is correct |
27 |
Correct |
20 ms |
2640 KB |
Output is correct |
28 |
Correct |
28 ms |
2660 KB |
Output is correct |
29 |
Correct |
29 ms |
2640 KB |
Output is correct |
30 |
Correct |
15 ms |
2640 KB |
Output is correct |
31 |
Correct |
1 ms |
2384 KB |
Output is correct |
32 |
Correct |
1 ms |
2384 KB |
Output is correct |