#include "ricehub.h"
#include <bits/stdc++.h>
#define all(a) a.begin (), a.end ()
#define S second
#define MIN -1
#define MAX 1e9+7
#define F first
#define pb push_back
#define mk make_pair
using namespace std;
typedef vector <int> vi;
typedef long long int ll;
typedef pair<int, int> ii;
int besthub(int n, int l, int x[], long long b)
{
int maxi=MIN;
for(int i=1;i<=l;i++){
vi v;
for(int j=0;j<n;j++){
v.pb(abs(x[j]-i));
}
sort(all(v));
ll aux=0;
for(int j=0;j<v.size();j++){
if((aux+v[j])>b){
maxi=max(maxi, j);
break;
}else aux+=v[j];
if(j==n-1)maxi=max(maxi, j+1);
}
//cout<<maxi<<" ";
}//cout<<endl;
return maxi;
}/*
#define MAX_R 1000000
static int R, L;
static long long B;
static int X[MAX_R];
static int solution;
inline
void my_assert(int e) {if (!e) abort();}
static void read_input()
{
int i;
my_assert(3==scanf("%d %d %lld",&R,&L,&B));
for(i=0; i<R; i++)
my_assert(1==scanf("%d",&X[i]));
my_assert(1==scanf("%d",&solution));
}
int main()
{
int ans;
read_input();
ans = besthub(R,L,X,B);
if(ans==solution)
printf("Correct.\n");
else
printf("Incorrect. Returned %d instead of %d.\n",ans,solution);
return 0;
}
*/
Compilation message
ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:24:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=0;j<v.size();j++){
~^~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
256 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
256 KB |
Output is correct |
4 |
Correct |
5 ms |
256 KB |
Output is correct |
5 |
Correct |
5 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
256 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
6 ms |
384 KB |
Output is correct |
5 |
Correct |
6 ms |
256 KB |
Output is correct |
6 |
Correct |
7 ms |
256 KB |
Output is correct |
7 |
Correct |
6 ms |
384 KB |
Output is correct |
8 |
Correct |
6 ms |
384 KB |
Output is correct |
9 |
Correct |
4 ms |
384 KB |
Output is correct |
10 |
Correct |
4 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
256 KB |
Output is correct |
12 |
Correct |
4 ms |
256 KB |
Output is correct |
13 |
Correct |
5 ms |
256 KB |
Output is correct |
14 |
Correct |
5 ms |
256 KB |
Output is correct |
15 |
Correct |
10 ms |
256 KB |
Output is correct |
16 |
Correct |
6 ms |
256 KB |
Output is correct |
17 |
Correct |
5 ms |
384 KB |
Output is correct |
18 |
Correct |
4 ms |
384 KB |
Output is correct |
19 |
Correct |
7 ms |
256 KB |
Output is correct |
20 |
Correct |
6 ms |
256 KB |
Output is correct |
21 |
Correct |
11 ms |
256 KB |
Output is correct |
22 |
Correct |
12 ms |
384 KB |
Output is correct |
23 |
Correct |
112 ms |
256 KB |
Output is correct |
24 |
Correct |
112 ms |
384 KB |
Output is correct |
25 |
Correct |
112 ms |
256 KB |
Output is correct |
26 |
Correct |
109 ms |
404 KB |
Output is correct |
27 |
Correct |
96 ms |
256 KB |
Output is correct |
28 |
Correct |
96 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
38 ms |
384 KB |
Output is correct |
2 |
Correct |
34 ms |
256 KB |
Output is correct |
3 |
Execution timed out |
1096 ms |
256 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1093 ms |
908 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |