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>
using namespace std;
int besthub(int R, int L, int X[] , long long B){
int best = 0;
for(int i = 0 ; i < R ; i++){
int ans = 0;
long long s = 0;
int l = i - 1 , r = i + 1;
while(l >= 0 || r < R){
if((l < 0) || (r < R && X[r] - X[i] <= X[i] - X[l])){
s += X[r] - X[i];
r++;
}
else if((r >= R) || (l >= 0 && X[i] - X[l] <= X[r] - X[i])){
s += X[i] - X[l];
l--;
}
if(s > B) break;
ans++;
}
best = max(best , ans);
if(best == R - 1) break;
}
return best + 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... |