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;
const long long INF = 1e18;
long long findGap(int T, int N) {
multiset < pair< long long,pair<long long,long long> > > st;
long long mn, mx;
MinMax(0ll,INF,&mn,&mx);
st.insert({-(mx-mn),{mn,mx}});
long long ans = 0;
if(N == 2){
return mx - mn;
}
if (T == 1){
for (int i=1;i<(N+1)/2;i++){
long long mmn, mmx;
MinMax(mn+1,mx-1,&mmn,&mmx);
ans = max(ans,mmn-mn);
ans = max(ans,mx-mmx);
mn = mmn;
mx = mmx;
}
ans = max(ans,mx-mn);
return ans;
}
long long dis = (mx-mn)/N;
vector < pair<long long,long long> > v;
for(long long i = mn; i <= mx; i++){
long long a, b;
MinMax(i,i+dis,&a,&b);
v.push_back({a,b});
}
for(int i = 0; i < v.size(); i++)
ans = max(ans,v[i].second-v[i].first);
return ans;
return 0;
}
Compilation message (stderr)
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:40:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0; i < v.size(); i++)
^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |