이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
int besthub(int R, int L, int X[], long long B) {
auto cost = [&](int x, int y) { return abs(X[x] - X[y]); };
int ans = -1;
for (int i = 0; i < R; i++) {
int cans = 0;
long long cb = B;
int l, r;
l = i;
r = i + 1;
while (1) {
int t;
if (l == -1 && r != R)
t = r++;
else if (r == R && l != -1)
t = l--;
else if (cost(i, l) < cost(i, r))
t = l--;
else
t = r++;
if (cb - cost(i, t) >= 0) {
cb -= cost(i, t);
cans++;
} else {
break;
}
if (l == -1 && r == R)
break;
}
ans = max(cans, 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... |