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 "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define ff first
#define ss second
ll ttt;
const ll INF=1e18;
const ll MOD=1e9+7;
const ll N=200007;
ll n,m,k;
ll a[N];
int besthub(int R, int L, int X[], ll B){
n=R;
m=L;
for(int i=0;i<n;i++){
a[i]=X[i];
}
k=B;
int l=0,r=0;
int ans=0;
ll curval=0;
int mid=0;
while(l<n&&r<n){
if(curval<=k){
ans=max(ans,r-l+1);
r++;
if((l+r)%2==0){
mid++;
}
curval+=abs(a[mid]-a[r]);
}
else{
l++;
if((l+r)%2==0){
mid++;
}
curval-=abs(a[mid]-a[l-1]);
}
// cout<<l<<" "<<r<<": "<<curval<<endl;
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |