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];
ll calc(int l, int r){
int mid=(l+r)/2;
ll val=0;
for(int i=l;i<=r;i++){
val+=abs(a[i]-a[mid]);
}
return val;
}
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;
while(l<n&&r<n){
if(calc(l,r)<=k){
ans=max(ans,r-l+1);
r++;
}
else{
l++;
}
}
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... |