이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;
typedef long long ll;
//#define int ll
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int besthub(int R, int L, int X[], long long B){
ll sx=0,dx=R+1;
while(sx<dx-1){
ll m=(sx+dx)/2;
ll tot=0;
ll mi=1e18;
int pos=m/2;
for(int i=0;i<m;i++){
tot+=abs(X[i]-X[pos]);
}
mi=min(mi,tot);
for(int i=m;i<R;i++){
pos++;
tot-=(ll)X[pos-1]-(ll)X[i-m];
tot+=(ll)(m)/2*((ll)X[pos]-X[pos-1]);
tot-=(ll)(m-1)/2*((ll)X[pos]-X[pos-1]);
tot+=(ll)X[i]-X[pos];
mi=min(mi,tot);
}
if(mi<=B)sx=m;
else dx=m;
}
return (int)sx;
}
# | 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... |