Submission #157730

# Submission time Handle Problem Language Result Execution time Memory
157730 2019-10-12T18:51:53 Z lukameladze Rice Hub (IOI11_ricehub) C++14
Compilation error
0 ms 0 KB
# include<bits/stdc++.h>
using namespace std;
long long r,l,b,n,pos[100005],w,sum[100005],mid,shua,ans,sn,sm,ri;
int besthub(int r,int l,int x[],int b) 
{
	cin>>r>>l>>b;
	for (long long i=1; i<=r; i++)
	{
		pos[i]=x[i-1];
		w+=pos[i];
		sum[i]=w;
	}
	l=1;
	ri=r;
	while (l<=ri)
	{
		mid=(l+ri)/2;
		for (long long i=1; i<=ri-mid+1; i++)
		{
			shua=(i+i+mid)/2;
			sn=sum[shua-1]-sum[i-1];
			sm=sum[i+mid-1]-sum[shua];
			if ((pos[shua]*(shua-i)-sn)+sm-(pos[shua]*(i+mid-1-shua))<=b)
			{
				ans=mid;
				l=mid+1;
			}
			else
			{
				ri=mid-1;
			}
		}
	}
	return ans;
}

Compilation message

/tmp/cc129kqI.o: In function `main':
grader.cpp:(.text.startup+0x92): undefined reference to `besthub(int, int, int*, long long)'
collect2: error: ld returned 1 exit status