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;
stack<long long> st;
vector<long long> arr;
long long findGap(int T, int N)
{
long long ans=LLONG_MIN;
long long l=0,r=1e18,mn,mx;
while(l<=r){
MinMax(l,r,&mn,&mx);
if(mn==-1) break;
arr.push_back(mn);
if(mn!=mx) st.push(mx);
l=mn+1,r=mx-1;
}
while(!st.empty()) arr.push_back(st.top()),st.pop();
for(int i=0;i<N-1;i++){
ans=max(ans,arr[i+1]-arr[i]);
}
/*for(int i=0;i<N;i++) cout<<arr[i] <<" ";
cout<<"\n\n";*/
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |