# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
234266 | pere_gil | Rice Hub (IOI11_ricehub) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "ricehub.h"
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
ll absolute(int a, int b){
int res=a-b;
if(res<0) res*=-1;
return res;
}
int besthub(int R, int L, int X[], ll B)
{
ll big=0;
for(int i=1;i<=L;i++){
ll transported=0;
ll a=0;
std::vector<ll> dist;
for(int j=0;j<R;j++) dist.push_back(absolute(i-X[j]));
sort(dist.begin(), dist.end());
for(int j=0;j<R;j++){
if(transported+dist[j]<=B){ transported+=dist[j]; a++; }
else break;
}
big=max(big, a);
}
return big;
}