#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;
int besthub(int R, int L, int X[], long long B) {
int ans = 0;
for(int i = 0; i < R; i++) {
int l = i - 1,r = i + 1;
int b = B,cnt = 1;
while(true) {
if(l < 0) {
if(r < R && X[r] - X[i] <= b) {
cnt += 1;
b -= X[r++] - X[i];
continue;
}
break;
}
if(r >= R) {
if(l >= 0 && X[i] - X[l] <= b) {
cnt += 1;
b -= X[i] - X[l--];
continue;
}
break;
}
if(X[r] - X[i] < X[i] - X[l]) {
if(X[r] - X[i] <= b) {
cnt += 1;
b -= X[r++] - X[i];
continue;
}
break;
}
if(X[i] - X[l] <= b) {
cnt += 1;
b -= X[i] - X[l--];
continue;
}
break;
}
ans = max(ans,cnt);
}
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... |