#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Incorrect |
16 ms |
464 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
604 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |