#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
int besthub(int r, int l, int x[], ll b){
ll b_ = b;
int ans = 0;
for(int k = 0; k < r; ++k){
vector<int> v;
for(int i = 0; i < r; ++i)
v.pb(abs(x[k]-x[i]));
sort(all(v));
ll sm = 0;
int cnt = 0;
for(auto i : v){
sm += i;
if(sm > b)
break;
cnt++;
}
ans = max(ans, cnt);
}
return ans;
}
// const int N = 20;
// int a[N];
// int main(){
// int r, l;
// ll b;
// r = 5, l = 20, b = 6;
// a[0] = 1, a[1] = 2, a[2] = 10, a[3] = 12, a[4] = 14;
// printf("%d\n", besthub(r, l, a, b));
// return 0;
// }
Compilation message
ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:10:8: warning: unused variable 'b_' [-Wunused-variable]
10 | ll b_ = b;
| ^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
2 ms |
348 KB |
Output is correct |
22 |
Correct |
2 ms |
400 KB |
Output is correct |
23 |
Correct |
4 ms |
348 KB |
Output is correct |
24 |
Correct |
5 ms |
348 KB |
Output is correct |
25 |
Correct |
4 ms |
348 KB |
Output is correct |
26 |
Correct |
4 ms |
344 KB |
Output is correct |
27 |
Correct |
4 ms |
348 KB |
Output is correct |
28 |
Correct |
4 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
13 ms |
460 KB |
Output is correct |
4 |
Correct |
13 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Correct |
8 ms |
460 KB |
Output is correct |
8 |
Correct |
8 ms |
464 KB |
Output is correct |
9 |
Correct |
4 ms |
344 KB |
Output is correct |
10 |
Correct |
4 ms |
448 KB |
Output is correct |
11 |
Correct |
10 ms |
464 KB |
Output is correct |
12 |
Correct |
10 ms |
464 KB |
Output is correct |
13 |
Correct |
16 ms |
464 KB |
Output is correct |
14 |
Correct |
17 ms |
348 KB |
Output is correct |
15 |
Correct |
4 ms |
448 KB |
Output is correct |
16 |
Correct |
4 ms |
344 KB |
Output is correct |
17 |
Correct |
12 ms |
600 KB |
Output is correct |
18 |
Correct |
14 ms |
344 KB |
Output is correct |
19 |
Correct |
16 ms |
468 KB |
Output is correct |
20 |
Correct |
17 ms |
348 KB |
Output is correct |
21 |
Correct |
323 ms |
596 KB |
Output is correct |
22 |
Correct |
303 ms |
532 KB |
Output is correct |
23 |
Correct |
574 ms |
348 KB |
Output is correct |
24 |
Correct |
641 ms |
592 KB |
Output is correct |
25 |
Correct |
605 ms |
540 KB |
Output is correct |
26 |
Correct |
593 ms |
348 KB |
Output is correct |
27 |
Correct |
490 ms |
540 KB |
Output is correct |
28 |
Correct |
508 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1058 ms |
900 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |