#include <bits/stdc++.h>
#include "ricehub.h"
#define lp(i,a,b) for(int i = a ; i < b ; i++ )
#define pii pair<int,int>
#define ff first
#define ss second
#define mk make_pair
#define pb push_back
#define ll long long
const int MAXN = 5005 ;
const int inf = 1e9 + 10 ;
using namespace std ;
//Declarations
int r , l ;
ll b ;
int x[MAXN] ;
int test(int k)
{
int ans = 0 ;
vector<int> d ;
lp(i,0,r)
d.pb( abs( x[k] - x[i] ) ) ;
sort( d.begin() , d.end() ) ;
int ind = 0 , B = b ;
while( ind < d.size() )
{
if( B - d[ind] >= 0 ) ans++ , B -= d[ind++] ;
else break ;
}
return ans ;
}
int besthub(int R , int L , int X[] , ll B)
{
//Make them global
r = R ; l = L ; b = B ;
lp(i,0,R) x[i] = X[i] ;
sort( x , x+R ) ;
int ans = -inf ;
lp(i,0,r) ans = max(ans , test(i) ) ;
return ans ;
}
Compilation message
ricehub.cpp: In function 'int test(int)':
ricehub.cpp:35:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while( ind < d.size() )
~~~~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
3 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
256 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
384 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
2 ms |
256 KB |
Output is correct |
14 |
Correct |
2 ms |
304 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
2 ms |
384 KB |
Output is correct |
17 |
Correct |
2 ms |
256 KB |
Output is correct |
18 |
Correct |
2 ms |
384 KB |
Output is correct |
19 |
Correct |
2 ms |
256 KB |
Output is correct |
20 |
Correct |
2 ms |
256 KB |
Output is correct |
21 |
Correct |
5 ms |
384 KB |
Output is correct |
22 |
Correct |
5 ms |
384 KB |
Output is correct |
23 |
Correct |
7 ms |
256 KB |
Output is correct |
24 |
Correct |
8 ms |
384 KB |
Output is correct |
25 |
Correct |
7 ms |
384 KB |
Output is correct |
26 |
Correct |
7 ms |
384 KB |
Output is correct |
27 |
Correct |
7 ms |
384 KB |
Output is correct |
28 |
Correct |
7 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
20 ms |
384 KB |
Output is correct |
4 |
Correct |
20 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
13 ms |
384 KB |
Output is correct |
8 |
Correct |
13 ms |
256 KB |
Output is correct |
9 |
Correct |
7 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 |
16 ms |
384 KB |
Output is correct |
13 |
Correct |
25 ms |
420 KB |
Output is correct |
14 |
Correct |
25 ms |
384 KB |
Output is correct |
15 |
Correct |
7 ms |
256 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 |
33 ms |
384 KB |
Output is correct |
20 |
Correct |
24 ms |
384 KB |
Output is correct |
21 |
Correct |
374 ms |
384 KB |
Output is correct |
22 |
Correct |
380 ms |
448 KB |
Output is correct |
23 |
Correct |
801 ms |
536 KB |
Output is correct |
24 |
Correct |
764 ms |
384 KB |
Output is correct |
25 |
Correct |
716 ms |
512 KB |
Output is correct |
26 |
Correct |
752 ms |
512 KB |
Output is correct |
27 |
Correct |
633 ms |
632 KB |
Output is correct |
28 |
Correct |
624 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1078 ms |
848 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |