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;
ll findGap(int T, int N)
{
ll l, r, ans=0;
MinMax(0,1e18, &l, &r);
if(T-1) {
ll sz = (r-l+N-2)/(N-1);
ll x,y,z=l;
for(ll i=0;i<N-1;i++) {
MinMax(min(r-1, l+i*sz),min(r,l+(i+1)*sz)-1,&x,&y);
if(x+1)ans=max(ans,x-z),z=y;
}
ans=max(ans,r-z);
} else {
for(ll i=0;i<(N-1>>1);i++) {
ll pl, pr; MinMax(min(r-1,l+1),r-1, &pl, &pr);ans = max(max(pl-l, r-pr), ans);l=pl,r=pr;
}
if(N&1^1)ans=max(ans,r-l);
}
return ans;
}
Compilation message (stderr)
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:19:24: warning: suggest parentheses around '-' inside '>>' [-Wparentheses]
19 | for(ll i=0;i<(N-1>>1);i++) {
| ~^~
gap.cpp:22:13: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
22 | if(N&1^1)ans=max(ans,r-l);
| ~^~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |