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 <bits/stdc++.h>
#define ll long long
using namespace std;
const int nax = 1e5 + 5;
int n, maxi, a[nax];
ll b;
// Subtask 3
int solve() {
int ans = 0;
for (int i = 1; i <= n; ++i) {
// select a[i] as the position
priority_queue<int, vector<int>, greater<int>> pq;
for (int j = 1; j <= n; ++j) {
pq.push(abs(a[i] - a[j]));
}
int cnt = 0, curr = 0;
while (!pq.empty() && curr <= b) {
++cnt;
curr += pq.top();
pq.pop();
}
if (curr > b) --cnt;
ans = max(ans, cnt);
}
return ans;
}
int besthub(int R, int L, int X[], long long B) {
n = R;
maxi = L;
for (int i = 0; i < R; ++i) a[i + 1] = X[i];
b = B;
return solve();
}
# | 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... |