Submission #157722

# Submission time Handle Problem Language Result Execution time Memory
157722 2019-10-12T18:43:11 Z keta_tsimakuridze Rice Hub (IOI11_ricehub) C++14
0 / 100
8 ms 888 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,int 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;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 380 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 888 KB Output isn't correct
2 Halted 0 ms 0 KB -