이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "ricehub.h"
typedef std::pair<long long,long long> pli;
pli custo(long long P,long long R,int X[],long long B){
std::vector<long long> vec;
for(int i=0;i!=R;++i){
long long dist = abs(X[i]-P);
vec.push_back(dist);
}
std::sort(vec.begin(),vec.end());
int res=0;
for(auto&x:vec){
if(x<=B){
++res;
B-=x;
continue;
}
}
return {res,B};
}
int besthub(int R, int L, int X[], long long B)
{
long long la=0,ra=L-1;
while(ra-la>1){
int m = (la+ra+1)/2;
pli alpha = custo(m,R,X,B);
pli beta = custo(m+1,R,X,B);
if(alpha>beta){
ra=m;
}else la=m;
}
return custo(la+1,R,X,B).first;
}
# | 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... |