#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5+5;
int a[N], n;
long long b;
int check(int pos){
vector<int> v;
for(int i=0;i<n;i++){
v.push_back(abs(a[i]-pos));
}sort(v.begin(), v.end());
int i=0;
long long B = b;
int cnt = 0;
while(i < n && B >= 0){
if(v[i] > B)break;
B -= (long long)v[i], i++;
cnt++;
}return cnt;
}
int besthub(int R, int L, int X[], long long B){
n = R;
b = B;
for(int i=0;i<n;i++)a[i] = X[i];
int ans = 0;
for(int i=0;i<n;i++){
ans = max(check(a[i]), ans);
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
256 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 |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 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 |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
256 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
1 ms |
384 KB |
Output is correct |
17 |
Correct |
1 ms |
384 KB |
Output is correct |
18 |
Correct |
1 ms |
384 KB |
Output is correct |
19 |
Correct |
1 ms |
384 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 |
7 ms |
384 KB |
Output is correct |
24 |
Correct |
7 ms |
384 KB |
Output is correct |
25 |
Correct |
6 ms |
384 KB |
Output is correct |
26 |
Correct |
7 ms |
384 KB |
Output is correct |
27 |
Correct |
6 ms |
384 KB |
Output is correct |
28 |
Correct |
6 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
25 ms |
384 KB |
Output is correct |
4 |
Correct |
21 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
512 KB |
Output is correct |
7 |
Correct |
14 ms |
384 KB |
Output is correct |
8 |
Correct |
16 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 |
16 ms |
384 KB |
Output is correct |
12 |
Correct |
17 ms |
384 KB |
Output is correct |
13 |
Correct |
26 ms |
384 KB |
Output is correct |
14 |
Correct |
26 ms |
384 KB |
Output is correct |
15 |
Correct |
6 ms |
384 KB |
Output is correct |
16 |
Correct |
7 ms |
384 KB |
Output is correct |
17 |
Correct |
16 ms |
384 KB |
Output is correct |
18 |
Correct |
16 ms |
384 KB |
Output is correct |
19 |
Correct |
25 ms |
384 KB |
Output is correct |
20 |
Correct |
27 ms |
384 KB |
Output is correct |
21 |
Correct |
410 ms |
504 KB |
Output is correct |
22 |
Correct |
399 ms |
504 KB |
Output is correct |
23 |
Correct |
856 ms |
504 KB |
Output is correct |
24 |
Correct |
849 ms |
504 KB |
Output is correct |
25 |
Correct |
806 ms |
500 KB |
Output is correct |
26 |
Correct |
794 ms |
504 KB |
Output is correct |
27 |
Correct |
721 ms |
384 KB |
Output is correct |
28 |
Correct |
719 ms |
504 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1086 ms |
1020 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |