#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=1,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){
la=m;
}else ra=m;
}
return custo(la,R,X,B).first;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
304 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
2 ms |
204 KB |
Output is correct |
4 |
Correct |
2 ms |
204 KB |
Output is correct |
5 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
18 ms |
932 KB |
Output is correct |
2 |
Correct |
19 ms |
1048 KB |
Output is correct |
3 |
Correct |
501 ms |
3604 KB |
Output is correct |
4 |
Correct |
493 ms |
3660 KB |
Output is correct |
5 |
Incorrect |
65 ms |
1776 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |