이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
int besthub(int R, int L, int X[], long long B)
{
int l = 1, r = R;
while(l + 1 < r){
int m = (l + r + 1) / 2;
ll cost = 0;
int base = (m) / 2;
int b = 0, j = m - 1;
for(int i = 0; i < m; ++i){
cost += abs(X[base] - X[i]);
}
bool ok = cost <= B;
while(!ok && j < R - 1){
ll x = X[base + 1] - X[base];
cost += x * (base + 1 - b);
cost -= x * (j - base);
cost -= X[base] - X[b] + x;
++b; ++j; ++base;
cost += X[j] - X[base];
cerr << b << " " << j << " " << base << " " << cost << endl;
if(cost <= B){
ok = true;
}
}
if(ok){
l = m;
}
else{
r = m;
}
}
return l;
}
# | 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... |