#include "ricehub.h"
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int besthub(int r, int l, int x[], long long b)
{
int ans = 0;
for(int i=0;i<r;i++)
{
vector<int> cost;
for(int j=0;j<r;j++)
cost.push_back(abs(x[i] - x[j]));
sort(cost.begin(), cost.end());
ll sum = 0;
int cur = 0;
while(sum <= b)
{
if(cur >= r)
break;
sum += cost[cur];
cur++;
}
if(sum > b)
cur--;
ans = max(ans, cur);
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
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 |
# |
Verdict |
Execution time |
Memory |
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 |
1 ms |
308 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
316 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
312 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
1 ms |
256 KB |
Output is correct |
17 |
Correct |
1 ms |
212 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 |
312 KB |
Output is correct |
21 |
Correct |
4 ms |
212 KB |
Output is correct |
22 |
Correct |
3 ms |
212 KB |
Output is correct |
23 |
Correct |
7 ms |
312 KB |
Output is correct |
24 |
Correct |
5 ms |
212 KB |
Output is correct |
25 |
Correct |
5 ms |
316 KB |
Output is correct |
26 |
Correct |
5 ms |
312 KB |
Output is correct |
27 |
Correct |
4 ms |
316 KB |
Output is correct |
28 |
Correct |
6 ms |
316 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
15 ms |
320 KB |
Output is correct |
4 |
Correct |
14 ms |
212 KB |
Output is correct |
5 |
Correct |
3 ms |
212 KB |
Output is correct |
6 |
Correct |
3 ms |
212 KB |
Output is correct |
7 |
Correct |
14 ms |
212 KB |
Output is correct |
8 |
Correct |
12 ms |
316 KB |
Output is correct |
9 |
Correct |
5 ms |
212 KB |
Output is correct |
10 |
Correct |
6 ms |
312 KB |
Output is correct |
11 |
Correct |
15 ms |
316 KB |
Output is correct |
12 |
Correct |
16 ms |
316 KB |
Output is correct |
13 |
Correct |
19 ms |
320 KB |
Output is correct |
14 |
Correct |
25 ms |
212 KB |
Output is correct |
15 |
Correct |
4 ms |
212 KB |
Output is correct |
16 |
Correct |
5 ms |
312 KB |
Output is correct |
17 |
Correct |
12 ms |
320 KB |
Output is correct |
18 |
Correct |
12 ms |
316 KB |
Output is correct |
19 |
Correct |
17 ms |
316 KB |
Output is correct |
20 |
Correct |
17 ms |
212 KB |
Output is correct |
21 |
Correct |
305 ms |
360 KB |
Output is correct |
22 |
Correct |
439 ms |
340 KB |
Output is correct |
23 |
Correct |
617 ms |
360 KB |
Output is correct |
24 |
Correct |
614 ms |
364 KB |
Output is correct |
25 |
Correct |
568 ms |
340 KB |
Output is correct |
26 |
Correct |
584 ms |
340 KB |
Output is correct |
27 |
Correct |
511 ms |
372 KB |
Output is correct |
28 |
Correct |
525 ms |
360 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1078 ms |
648 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |