#include "ricehub.h"
#include <cstdlib>
#include <set>
#include <vector>
using namespace std;
int besthub(int R, int L, int X[], long long B) {
int ans = 0;
for (int i = 0; i < R; i++) {
// chooce rice hub
int tempB = B;
multiset <int> s;
for (int j = 0; j < R; j++)
s.emplace (abs (X[i] - X[j]));
int curans = 0;
while (s.size() && *s.begin() <= tempB) {
tempB -= *s.begin();
s.erase (s.begin());
curans++;
}
ans = max (curans, ans);
}
return ans;
}
# | 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... |