답안 #157733

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
157733 2019-10-12T18:54:09 Z lukameladze 쌀 창고 (IOI11_ricehub) C++14
컴파일 오류
0 ms 0 KB
# include<bits/stdc++.h>
using namespace std;
long long n,pos[100005],w,sum[100005],mid,shua,ans,sn,sm,ri;
long long besthub(long long r,long long l,long long x[],long long 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/ccd9cwTV.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