#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int besthub(int R, int L, int X[], long long B) {
vector<ll> lft;
vector<ll> rgt;
int best = 0;
int n = R;
for (int i = n - 1; i > 0; --i) {
rgt.push_back(X[i]);
}
for (int i = 0; i < n; ++i) {
ll leftm = B;
int cur = 0;
int li = lft.size() - 1;
int ri = rgt.size() - 1;
while (true) {
ll leftd = li >= 0 ? abs(lft[li] - X[i]) : 1e18;
ll rightd = ri >= 0 ? abs(rgt[ri] - X[i]) : 1e18;
if (min(leftd, rightd) > leftm) break;
cur++;
if (leftd < rightd) {
leftm -= leftd;
li--;
} else {
leftm -= rightd;
ri--;
}
}
best = max(best, cur);
lft.push_back(X[i]);
rgt.pop_back();
}
return best;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
888 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |