#include "ricehub.h"
#include <bits/stdc++.h>
#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));
}
using namespace std;
int besthub(int R,int L,int X[], long long B){
// cout<<"a"<<endl;
long long ma=-1;
for(int i=0;i<R;i++){
for(int j=i;j<R;j++){
// cout<<i<<" "<<j<<endl;
vector<int>rp;
for(int k=i;k<=j;k++){
rp.push_back(X[k]);
}
int mi=(i+j)/2;
mi=X[mi];
// cout<<i<<" "<<j<<endl;
bool sw=0;
long long b=B;
for(int k=0;k<rp.size();k++){
b-=abs(mi-rp[k]);
if(b<0){
sw=1;
break;
}
//c++;
}
if(sw==0 or b>=0){
// cout<<i<<" "<<j<<" "<<rp.size()<<endl;
long long tam=rp.size();
ma=max(ma,tam);
}
}
}
return ma;
}
int main()
{
int ans;
read_input();
// cout<<"a"<<endl;
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:37:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int k=0;k<rp.size();k++){
~^~~~~~~~~~
/tmp/ccF3886A.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/cc37quYs.o:ricehub.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status