#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
int besthub(int R, int L, int X[], long long B) {
int mx = 0;
for (int i = 0; i < R; i++) {
vector<int> dist;
for (int j = 0; j < R; j++) {
dist.emplace_back( abs (X[i] - X[j] ) );
}
sort (dist.begin(), dist.end());
long long cur = B;
int got = 0;
for (int i = 0; i < R; i++) {
if (cur - dist[i] >= 0) {
cur -= dist[i];
++got;
} else break;
}
mx = max (mx, got);
}
return mx;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
4 ms |
256 KB |
Output is correct |
3 |
Correct |
4 ms |
256 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
4 ms |
128 KB |
Output is correct |
3 |
Correct |
4 ms |
256 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
256 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
4 ms |
256 KB |
Output is correct |
10 |
Correct |
5 ms |
256 KB |
Output is correct |
11 |
Correct |
4 ms |
256 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
16 |
Correct |
5 ms |
384 KB |
Output is correct |
17 |
Correct |
5 ms |
384 KB |
Output is correct |
18 |
Correct |
4 ms |
256 KB |
Output is correct |
19 |
Correct |
5 ms |
256 KB |
Output is correct |
20 |
Correct |
5 ms |
256 KB |
Output is correct |
21 |
Correct |
8 ms |
256 KB |
Output is correct |
22 |
Correct |
8 ms |
384 KB |
Output is correct |
23 |
Correct |
11 ms |
384 KB |
Output is correct |
24 |
Correct |
11 ms |
384 KB |
Output is correct |
25 |
Correct |
11 ms |
256 KB |
Output is correct |
26 |
Correct |
10 ms |
256 KB |
Output is correct |
27 |
Correct |
10 ms |
256 KB |
Output is correct |
28 |
Correct |
10 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
24 ms |
256 KB |
Output is correct |
4 |
Correct |
24 ms |
384 KB |
Output is correct |
5 |
Correct |
8 ms |
384 KB |
Output is correct |
6 |
Correct |
8 ms |
384 KB |
Output is correct |
7 |
Correct |
18 ms |
384 KB |
Output is correct |
8 |
Correct |
18 ms |
256 KB |
Output is correct |
9 |
Correct |
10 ms |
256 KB |
Output is correct |
10 |
Correct |
10 ms |
384 KB |
Output is correct |
11 |
Correct |
20 ms |
376 KB |
Output is correct |
12 |
Correct |
21 ms |
384 KB |
Output is correct |
13 |
Correct |
29 ms |
384 KB |
Output is correct |
14 |
Correct |
29 ms |
384 KB |
Output is correct |
15 |
Correct |
10 ms |
256 KB |
Output is correct |
16 |
Correct |
10 ms |
256 KB |
Output is correct |
17 |
Correct |
19 ms |
384 KB |
Output is correct |
18 |
Correct |
20 ms |
256 KB |
Output is correct |
19 |
Correct |
28 ms |
384 KB |
Output is correct |
20 |
Correct |
28 ms |
372 KB |
Output is correct |
21 |
Correct |
409 ms |
384 KB |
Output is correct |
22 |
Correct |
402 ms |
504 KB |
Output is correct |
23 |
Correct |
825 ms |
508 KB |
Output is correct |
24 |
Correct |
809 ms |
444 KB |
Output is correct |
25 |
Correct |
767 ms |
384 KB |
Output is correct |
26 |
Correct |
748 ms |
504 KB |
Output is correct |
27 |
Correct |
685 ms |
504 KB |
Output is correct |
28 |
Correct |
674 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1080 ms |
852 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |