#include "ricehub.h"
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
ll get(int x, int n, int v[], ll b){
vector<ll> cost(n);
for(int i=0;i<n;i++)
cost[i]=abs(x-v[i]);
sort(cost.begin(),cost.end());
ll res=0;
ll act_cost=0;
for(int i=0;i<n;i++){
if(act_cost+cost[i]<=b){
act_cost+=cost[i];
res++;
}
else return res;
}
return res;
}
int besthub(int n, int r, int v[], ll b){
ll res=0;
for(int i=0;i<n;i++)
res=max(res,get(v[i],n,v,b));
return res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
300 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
204 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
3 ms |
204 KB |
Output is correct |
22 |
Correct |
3 ms |
300 KB |
Output is correct |
23 |
Correct |
6 ms |
204 KB |
Output is correct |
24 |
Correct |
7 ms |
204 KB |
Output is correct |
25 |
Correct |
6 ms |
204 KB |
Output is correct |
26 |
Correct |
6 ms |
204 KB |
Output is correct |
27 |
Correct |
6 ms |
204 KB |
Output is correct |
28 |
Correct |
6 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
20 ms |
320 KB |
Output is correct |
4 |
Correct |
19 ms |
324 KB |
Output is correct |
5 |
Correct |
3 ms |
204 KB |
Output is correct |
6 |
Correct |
3 ms |
204 KB |
Output is correct |
7 |
Correct |
14 ms |
320 KB |
Output is correct |
8 |
Correct |
14 ms |
204 KB |
Output is correct |
9 |
Correct |
6 ms |
204 KB |
Output is correct |
10 |
Correct |
6 ms |
204 KB |
Output is correct |
11 |
Correct |
15 ms |
204 KB |
Output is correct |
12 |
Correct |
16 ms |
204 KB |
Output is correct |
13 |
Correct |
27 ms |
204 KB |
Output is correct |
14 |
Correct |
24 ms |
204 KB |
Output is correct |
15 |
Correct |
8 ms |
204 KB |
Output is correct |
16 |
Correct |
6 ms |
308 KB |
Output is correct |
17 |
Correct |
15 ms |
320 KB |
Output is correct |
18 |
Correct |
15 ms |
204 KB |
Output is correct |
19 |
Correct |
33 ms |
204 KB |
Output is correct |
20 |
Correct |
37 ms |
204 KB |
Output is correct |
21 |
Correct |
431 ms |
452 KB |
Output is correct |
22 |
Correct |
435 ms |
364 KB |
Output is correct |
23 |
Correct |
854 ms |
372 KB |
Output is correct |
24 |
Correct |
858 ms |
376 KB |
Output is correct |
25 |
Correct |
769 ms |
380 KB |
Output is correct |
26 |
Correct |
780 ms |
384 KB |
Output is correct |
27 |
Correct |
698 ms |
380 KB |
Output is correct |
28 |
Correct |
703 ms |
380 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1081 ms |
684 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |