Submission #157720

# Submission time Handle Problem Language Result Execution time Memory
157720 2019-10-12T18:42:29 Z keta_tsimakuridze Rice Hub (IOI11_ricehub) C++14
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
long long L,R,k,prefsum[100005],mid,pas,ans,a[1000005],r,l,b,x[100005],middl,cur,cur1,curans;
	
int besthub(int r,long long l,int x[],long long b ){
	cin>>r>>l;
	for(k=0;k<r;k++)
	cin>>x[k];
	cin>>b;
	
	for(k=1;k<=r;k++){
	a[k]=x[k-1];	prefsum[k]=prefsum[k-1]+a[k];
	}
	
	
for(k=1;k<=r;k++){

	//	cout<<k<<"+"<<endl;
		L=k; R=r;
		while(L<=R){
			mid=(L+R)/2;
		l=k;//cout<<1;
			if((mid-l+1)%2==1){
				
				middl=(mid-l+1)/2+1;
				cur=prefsum[mid]-prefsum[middl]-a[k]*(mid-middl);
				
				cur+=a[k]*(middl-k)-prefsum[k];
				curans=mid-k+1;
			}
			else{
				middl=(mid-l+1)/2+1;
				cur=prefsum[mid]-prefsum[middl]-a[k]*(mid-middl);
				
				cur+=a[k]*(middl-k)-prefsum[k];
				middl=(mid-l+1)/2;
				cur1=prefsum[mid]-prefsum[middl]-a[k]*(mid-middl);
				
				cur1+=a[k]*(middl-k)-prefsum[k];
				cur=min(cur,cur1);
				curans=mid-k+1;
				
			}
			if(cur<=b) {
				L=mid+1; pas=curans;
			}
			else R=mid-1;
		}
		ans=max(ans,pas);
		
		
	}
	
	return ans;
}

Compilation message

/tmp/ccxuNX1M.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