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;
#define ll long long
int besthub(int r, int l, int x[], long long b) {
if (r > 5000) {
return 0;
}
int ans = 0, tempans;
vector<int> dis;
ll counter;
for (int i=0;i<r;i++) {
dis.clear(); counter = 0; tempans = 0;
for (int j=0;j<r;j++) {
dis.push_back(abs(x[i] - x[j]));
}
dis.push_back(INT32_MAX);
sort(dis.begin(),dis.end());
for (int j: dis) {
if (j == INT32_MAX || counter > b) {
tempans--;
break;
}
counter += j; tempans++;
}
ans = max(ans, tempans);
}
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... |