이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;
const int R = 1e5 + 5;
int xx[R];
long long s[R];
long long sum(int i, int j) {
if (i > j) {
return 0;
}
return (i == 0 ? s[j] : s[j] - s[i - 1]);
}
long long cost(int i, int j) {
int mid = (i + j) >> 1;
long long res = 0;
res += 1LL * xx[mid] * (mid - i + 1) - sum(i, mid);
if (mid + 1 <= j) {
res += sum(mid + 1, j) - 1LL * xx[mid] * (j - mid);
}
return res;
}
int besthub(int r, int l, int x[], long long b) {
for (int i = 0; i < r; i++) {
s[i] = (i == 0 ? x[i] : x[i] + s[i - 1]);
xx[i] = x[i];
}
int ans = 0;
for (int i = 0, j = 0; i < r; i++) {
while (j + 1 <= i && cost(j, i) > b) {
j++;
}
ans = max(ans, i - j + 1);
}
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... |