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