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 <bits/stdc++.h>
#include "gap.h"
using namespace std;
vector<long long> findnum(long long s,long long e){
long long a,b,m,n;
vector<long long> v1,v2,v;
MinMax(s,e,&a,&b);
if(a==-1||b==-1){
return v;
}
if(a==b){
v.push_back(a);
return v;
}
m=(a+b)/2;
n=m+1;
v1=findnum(a,m);
v2=findnum(n,b);
for(int i=0;i<v1.size();i++){
v.push_back(v1[i]);
}
for(int i=0;i<v2.size();i++){
v.push_back(v2[i]);
}
return v;
}
long long findGap(int T,int n){
long long s=0,e=1000000000000000000;
vector<long long> v;
long long a,b;
if(T==1){
long long arr[n];
for(int i=0;i<(n+1)/2;i++){
MinMax(s,e,&a,&b);
arr[i]=a;
arr[n-i-1]=b;
s=a+1;
e=b-1;
}
a=0;
for(int i=1;i<n;i++){
if(a<arr[i]-arr[i-1])
a=arr[i]-arr[i-1];
}
return a;
}
s=0;
e=1000000000000000000;
v=findnum(s,e);
for(int i=1;i<n;i++){
if(a<v[i]-v[i-1])
a=v[i]-v[i-1];
}
return a;
}
Compilation message (stderr)
gap.cpp: In function 'std::vector<long long int> findnum(long long int, long long int)':
gap.cpp:19:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<v1.size();i++){
~^~~~~~~~~~
gap.cpp:22:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0;i<v2.size();i++){
~^~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |