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