# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
224655 | jhtan | 쌀 창고 (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;
int besthub(int R, int L, int X[], long long B)
{
int mn = 2000000001;
int sol = 0;
for(int i=1; i<=L; i++) {
int s = 0, c = 0;
vector<int> V;
for(int j=0; j<X.size; j++) V.push_back(abs(i-X[j]));
sort(V.begin(), V.end());
for(int j=0; j<V.size; j++) {
if(s + V[j] <= B) {s += V[j]; c++;}
else break;
}
if(s < mn) {
mn = s;
sol = c;
}
}
return sol;
}