#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int nax = 1e5 + 5;
int n, maxi, a[nax];
ll b;
// Subtask 3
int solve() {
int ans = 0;
for (int i = 1; i <= n; ++i) {
// select a[i] as the position
priority_queue<int, vector<int>, greater<int>> pq;
for (int j = 1; j <= n; ++j) {
pq.push(abs(a[i] - a[j]));
}
int cnt = 0, curr = 0;
while (!pq.empty() && curr <= b) {
++cnt;
curr += pq.top();
pq.pop();
}
if (curr > b) --cnt;
ans = max(ans, cnt);
}
return ans;
}
int besthub(int R, int L, int X[], long long B) {
n = R;
maxi = L;
for (int i = 0; i < R; ++i) a[i + 1] = X[i];
b = B;
return solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
256 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
256 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
512 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
1 ms |
256 KB |
Output is correct |
17 |
Correct |
1 ms |
256 KB |
Output is correct |
18 |
Correct |
1 ms |
384 KB |
Output is correct |
19 |
Correct |
1 ms |
256 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
21 |
Correct |
4 ms |
384 KB |
Output is correct |
22 |
Correct |
4 ms |
384 KB |
Output is correct |
23 |
Correct |
14 ms |
384 KB |
Output is correct |
24 |
Correct |
14 ms |
384 KB |
Output is correct |
25 |
Correct |
14 ms |
384 KB |
Output is correct |
26 |
Correct |
14 ms |
384 KB |
Output is correct |
27 |
Correct |
9 ms |
384 KB |
Output is correct |
28 |
Correct |
9 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
57 ms |
384 KB |
Output is correct |
4 |
Correct |
53 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
512 KB |
Output is correct |
6 |
Correct |
3 ms |
256 KB |
Output is correct |
7 |
Correct |
14 ms |
384 KB |
Output is correct |
8 |
Correct |
14 ms |
384 KB |
Output is correct |
9 |
Correct |
6 ms |
384 KB |
Output is correct |
10 |
Correct |
7 ms |
384 KB |
Output is correct |
11 |
Correct |
15 ms |
384 KB |
Output is correct |
12 |
Correct |
14 ms |
384 KB |
Output is correct |
13 |
Correct |
70 ms |
504 KB |
Output is correct |
14 |
Correct |
64 ms |
384 KB |
Output is correct |
15 |
Correct |
9 ms |
512 KB |
Output is correct |
16 |
Correct |
9 ms |
384 KB |
Output is correct |
17 |
Correct |
44 ms |
384 KB |
Output is correct |
18 |
Correct |
42 ms |
384 KB |
Output is correct |
19 |
Correct |
69 ms |
384 KB |
Output is correct |
20 |
Correct |
70 ms |
384 KB |
Output is correct |
21 |
Correct |
317 ms |
512 KB |
Output is correct |
22 |
Correct |
317 ms |
508 KB |
Output is correct |
23 |
Execution timed out |
1069 ms |
384 KB |
Time limit exceeded |
24 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1046 ms |
788 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |