#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); dis.push_back(INT32_MAX);
sort(dis.begin(),dis.end());
for (int j: dis) {
if (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 |
0 ms |
348 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 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
344 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
3 ms |
348 KB |
Output is correct |
22 |
Correct |
2 ms |
348 KB |
Output is correct |
23 |
Correct |
5 ms |
348 KB |
Output is correct |
24 |
Correct |
5 ms |
348 KB |
Output is correct |
25 |
Correct |
9 ms |
452 KB |
Output is correct |
26 |
Correct |
5 ms |
600 KB |
Output is correct |
27 |
Correct |
5 ms |
344 KB |
Output is correct |
28 |
Correct |
5 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
16 ms |
348 KB |
Output is correct |
4 |
Correct |
28 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
344 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Correct |
9 ms |
348 KB |
Output is correct |
8 |
Correct |
18 ms |
460 KB |
Output is correct |
9 |
Correct |
8 ms |
348 KB |
Output is correct |
10 |
Correct |
5 ms |
452 KB |
Output is correct |
11 |
Correct |
21 ms |
348 KB |
Output is correct |
12 |
Correct |
14 ms |
460 KB |
Output is correct |
13 |
Correct |
22 ms |
348 KB |
Output is correct |
14 |
Correct |
21 ms |
348 KB |
Output is correct |
15 |
Correct |
5 ms |
452 KB |
Output is correct |
16 |
Correct |
5 ms |
348 KB |
Output is correct |
17 |
Correct |
14 ms |
468 KB |
Output is correct |
18 |
Correct |
13 ms |
344 KB |
Output is correct |
19 |
Correct |
24 ms |
348 KB |
Output is correct |
20 |
Correct |
22 ms |
468 KB |
Output is correct |
21 |
Correct |
282 ms |
520 KB |
Output is correct |
22 |
Correct |
296 ms |
344 KB |
Output is correct |
23 |
Correct |
788 ms |
524 KB |
Output is correct |
24 |
Correct |
810 ms |
600 KB |
Output is correct |
25 |
Correct |
779 ms |
348 KB |
Output is correct |
26 |
Correct |
791 ms |
348 KB |
Output is correct |
27 |
Correct |
761 ms |
536 KB |
Output is correct |
28 |
Correct |
782 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |