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>
#define ll long long
using namespace std;
const ll INF=1e18;
ll findGap(int T, int N){
ll mn, mx;
MinMax(0, INF, &mn, &mx);
if(N == 2)return mx - mn;
if(T == 1){
ll MN, MX, Ans=0;
N = (N - 1) / 2;
while(N--) MinMax(mn + 1, mx - 1, &MN, &MX), Ans = max(Ans, max(mx - MX - (ll)(MX == -1) * INF, MN - mn)), mn = MN, mx = MX;
return max(Ans, mx - mn);
}
ll l=mn, r=mx, ans=(mx-mn+1)/((ll)N)+1, Ans=0, MX=mn;
for (ll i=0; i<N; i++)
MinMax(l+1+i*ans, l+(i+1)*ans, &mn, &mx),
Ans=max(Ans, mn-MX),
MX=max(MX, mx);
return Ans;
}
Compilation message (stderr)
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:18:11: warning: unused variable 'r' [-Wunused-variable]
18 | ll l=mn, r=mx, ans=(mx-mn+1)/((ll)N)+1, Ans=0, MX=mn;
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |