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>
#include <stdio.h>
#include <stdlib.h>
#define MAX_R 1000000
using namespace std;
typedef long long ll;
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 besthub(int R, int L, int X[], long long B){
ll maxrice=0;ll maxcost=0;
for(int i=1;i<=L;i++){
vector<ll> v;
for(int j=0;j<R;j++){
ll h=abs(X[j]-i);
v.push_back(h);
}
ll curr=0;
sort(v.begin(),v.end());
ll pos=B;
for(int j=0;j<v.size();j++){
if(pos-v[j]>=0){
curr++;
pos-=v[j];
}
else{
break;
}
}
if(maxrice<curr){
maxrice=curr;
}
}
return maxrice;
}/*
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:36:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=0;j<v.size();j++){
~^~~~~~~~~
ricehub.cpp:26:19: warning: unused variable 'maxcost' [-Wunused-variable]
ll maxrice=0;ll maxcost=0;
^~~~~~~
ricehub.cpp: At global scope:
ricehub.cpp:17:13: warning: 'void read_input()' defined but not used [-Wunused-function]
static void read_input()
^~~~~~~~~~
# | 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... |