#include "ricehub.h"
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
int besthub(int r, int l, int X[], ll b)
{
vector<ll> x(r);
for (int i = 0; i < r; ++i) x[i] = X[i];
int maxRes = 0;
for (int i = 0; i < r; ++i)
{
vector<ll> sorted;
for (int j = 0; j < r; ++j) sorted.push_back(abs(x[i] - x[j]));
sort(sorted.begin(), sorted.end());
int res = 0;
ll sum = 0;
for (int j = 0; j < r; ++j)
{
if (sum + sorted[j] > b) break;
sum += sorted[j];
++res;
}
maxRes = max(maxRes, res);
}
return maxRes;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
300 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
300 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
296 KB |
Output is correct |
17 |
Correct |
1 ms |
300 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
4 ms |
300 KB |
Output is correct |
22 |
Correct |
3 ms |
212 KB |
Output is correct |
23 |
Correct |
5 ms |
212 KB |
Output is correct |
24 |
Correct |
6 ms |
212 KB |
Output is correct |
25 |
Correct |
5 ms |
212 KB |
Output is correct |
26 |
Correct |
5 ms |
212 KB |
Output is correct |
27 |
Correct |
6 ms |
212 KB |
Output is correct |
28 |
Correct |
6 ms |
304 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
304 KB |
Output is correct |
3 |
Correct |
18 ms |
332 KB |
Output is correct |
4 |
Correct |
18 ms |
304 KB |
Output is correct |
5 |
Correct |
6 ms |
308 KB |
Output is correct |
6 |
Correct |
4 ms |
308 KB |
Output is correct |
7 |
Correct |
13 ms |
336 KB |
Output is correct |
8 |
Correct |
12 ms |
212 KB |
Output is correct |
9 |
Correct |
5 ms |
212 KB |
Output is correct |
10 |
Correct |
6 ms |
312 KB |
Output is correct |
11 |
Correct |
14 ms |
212 KB |
Output is correct |
12 |
Correct |
13 ms |
340 KB |
Output is correct |
13 |
Correct |
23 ms |
212 KB |
Output is correct |
14 |
Correct |
22 ms |
212 KB |
Output is correct |
15 |
Correct |
6 ms |
212 KB |
Output is correct |
16 |
Correct |
7 ms |
312 KB |
Output is correct |
17 |
Correct |
14 ms |
212 KB |
Output is correct |
18 |
Correct |
14 ms |
336 KB |
Output is correct |
19 |
Correct |
21 ms |
332 KB |
Output is correct |
20 |
Correct |
22 ms |
212 KB |
Output is correct |
21 |
Correct |
359 ms |
468 KB |
Output is correct |
22 |
Correct |
374 ms |
596 KB |
Output is correct |
23 |
Correct |
756 ms |
476 KB |
Output is correct |
24 |
Correct |
744 ms |
480 KB |
Output is correct |
25 |
Correct |
681 ms |
484 KB |
Output is correct |
26 |
Correct |
699 ms |
484 KB |
Output is correct |
27 |
Correct |
614 ms |
484 KB |
Output is correct |
28 |
Correct |
638 ms |
480 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1092 ms |
1456 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |