이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;
typedef long long ll;
ll r, l, x, b;
vector<ll> pref;
int check(int R, int L, int *fields, ll B) {
int lo = L, hi = R;
while (lo < hi){
int mid = (lo + hi + 1)/2;
int k = (L + mid)/2;
ll cost = fields[k - 1]*(k - L + 1) - (pref[k] - pref[L - 1]) +(pref[mid] - pref[k]) - (mid - k)*fields[k-1];
if (cost > B) {
hi = mid - 1;
} else {
lo = mid;
}
}
return lo - L + 1;
}
int besthub(int R, int L, int fields[], ll B) {
pref.resize(R + 1);
for(int i = 0; i < R; i++){
pref[i+1] += pref[i];
pref[i+1] += fields[i];
}
int ans = INT_MIN;
for (int i = 1; i <= R; i++) {
ans = max(ans, check(R, i, fields, B));
}
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... |