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)
{
if(t == 1){
int cnt = 0;
vector<long long> v(n);
long long l = -1,r=INF+1;
while(cnt <= n-1-cnt){
MinMax(l+1,r-1,&v[cnt],&v[n-1-cnt]);
l = v[cnt];
r = v[n-1-cnt];
cnt++;
}
long long ans = 0;
for(int i = 1;i<n;i++){
ans = max(ans,v[i]-v[i-1]);
}
return ans;
}
if(t == 2){
long long x,y;
MinMax(0,INF,&x,&y);
long long ans = (y-x)/(n-1);
long long num = x;
long long last = x;
while(num != y){
long long tmp1,tmp2;
MinMax(num+1,num+ans,&tmp1,&tmp2);
if(tmp1 == -1){
num += ans;
}
else{
ans = max(ans,tmp1 - last);
num = tmp2;
last = tmp2;
}
}
return ans;
}
}
Compilation message (stderr)
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:43:1: warning: control reaches end of non-void function [-Wreturn-type]
43 | }
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |