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;
using pi = pair<int,int>;
int besthub(int R, int L, int X[], long long B)
{
int ans=0,mi,cnt=0,l,r;
long long int b = B;
for(int i=0;i<R;i++){
b=B;
l=i;r=i;
cnt=1;
//EXPAND
while(b>0){
mi=2e9;
//cout << r << ' ' << l << endl;
if(l>=1){
mi=min(abs(X[l-1]-X[i]),mi);
}
if(r<(R-1)){
mi=min(mi,abs(X[r+1]-X[i]));
}
if(mi==2e9)break;
if(b-mi < 0)break;
else{
cnt++;
b-=mi;
if(l>=1 && mi==abs(X[l-1]-X[i])){
l--;
}else{
r++;
}
}
}
ans=max(cnt,ans);
}
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... |