This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "gap.h"
#include<bits/stdc++.h>
using namespace std;
vector<long long> v;
long long findGap(int T, int n)
{
long long s=-1,tmps,tmpt;
long long t=1e18+1;
long long x=-1;
long long y=-1;
long long maxi=LLONG_MIN;
for(int i=1;i<=n/2;i++){
tmps=s,tmpt=t;
MinMax(s+1,t-1,&tmps,&tmpt);
v.push_back(tmps);
v.push_back(tmpt);
s=tmps,t=tmpt;
}
if(n%2==1){
tmps=s,tmpt=t;
MinMax(s+1,t-1,&tmps,&tmpt);
v.push_back(tmps);
}
int i=1;
long long xx;
sort(v.begin(),v.end());
for(auto a:v){
if(i!=1){
maxi=max(maxi,a-xx);
}
i++;
xx=a;
}
return maxi;
}
Compilation message (stderr)
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:9:18: warning: unused variable 'x' [-Wunused-variable]
9 | long long x=-1;
| ^
gap.cpp:10:18: warning: unused variable 'y' [-Wunused-variable]
10 | long long y=-1;
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |