이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dd;
typedef pair<ll , ll> ii;
typedef tuple < ll, ll, ll > tp;
#define ff first
#define ss second
#define pb push_back
#define in insert
int besthub(int R, int L, int x[], long long B){
vector < ll > pref(1, x[0]);
for(ll i = 1; i < R; i++){
pref.pb(pref.back() + x[i]);
}
ll l = 1, r = R;
ll ans = 0;
while(l <= r){
ll m = (l + r) / 2;
bool f = 0;
for(ll i = 0; i + m - 1 < R; i++){
ll k = (i + i + m - 1) / 2;
ll cost = (pref[i + m - 1] - x[k] * (i + m - 1 - k)) + (x[k] * (k - i + 1) - pref[k]);
cost -= pref[k];
if(i){
cost += pref[i - 1];
}
if(cost <= B){
ans = m; f = 1;
}
}
if(f){
l = m + 1;
}else{
r = m - 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... |