This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 (stderr)
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++){
~^~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |