이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#include "ricehub.h"
int besthub(int n, int L, int X[], ll B){
ll pre[n+1] = {0};
for(int i=0; i<n; ++i) pre[i+1] = (ll)X[i] + pre[i];
int ans = 1;
for(int i=1; i<=n; ++i){
int low = i, high = n;
while(low < high){
int mid = (low + high) / 2;
++mid;
int mx = (mid + i) / 2;
ll cost = 0, pos = X[mx - 1];
if(i < mx){
ll s = pre[mx-1] - pre[i-1];
cost += pos * (mx - i) - s;
}
if(mx < mid){
ll s = pre[mid] - pre[mx];
cost += s - pos * (mid - mx);
}
if(cost <= B) low = mid;
else high = mid - 1;
}
ans = max(ans, low - i + 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... |