이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
#include "ricehub.h"
using namespace std;
#define ll long long
int besthub(int R, int L, int X[], long long B)
{
vector<ll> a(R + 1);
for (int i = 1; i <= R; i++) {
a[i] = X[i - 1];
a[i] += a[i - 1];
}
int ans = 0;
int ptr = 1;
for (int i = 1; i <= R; i++) {
ptr = max(ptr, i);
while (ptr + 1 <= R) {
ll nmid = i + ((ptr + 1) - i + 1) / 2;
ll tot = (a[ptr + 1] - a[nmid]) - ((ll)(ptr + 1) - nmid) * X[nmid - 1];
tot += (((ll)(nmid - i + 1))) * X[nmid - 1] - (a[nmid] - a[i - 1]);
// cout << i << " -> " << ptr + 1 << " takes " << tot << endl;
if (tot > B) break;
ptr++;
}
ans = max(ans, ptr - i + 1);
// cout << i << " : " << ptr << endl;
}
return ans;
}
// int main() {
// int xx[5] = {1, 2, 10, 12, 14};
// cout << besthub(5, 20, xx, 6) << endl;
// }
# | 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... |