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;
#define ff first
#define ss second
#define pb push_back
#define ll long long
int besthub(int R, int L, int X[], long long B)
{
int n=R;
int ans=0;
for(int i=0;i<n;i++){
int l=-1,r=i+1;
ll k=B;
int cnt=0;
while(1){
if(l==-1 and r==n)break;
if(l==-1){
if(abs(X[r]-X[i])<=k){
cnt++;
k-=abs(X[r]-X[i]);
r++;
}
else{break;}
}
else if(r==n){
if(abs(X[l]-X[i])<=k){
cnt++;
k-=abs(X[l]-X[i]);
l--;
}
else{break;}
}
else{
ll a=abs(X[r]-X[i]),b=abs(X[l]-X[i]);
if(a<=b){
if(abs(X[r]-X[i])<=k){
cnt++;
k-=abs(X[r]-X[i]);
r++;
}
else{break;}
}
else{
if(abs(X[l]-X[i])<=k){
cnt++;
k-=abs(X[l]-X[i]);
l--;
}
else{break;}
}
}
}
ans=max(ans,cnt);
}
return ans+1;
}
# | 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... |