Submission #978407

# Submission time Handle Problem Language Result Execution time Memory
978407 2024-05-09T07:57:12 Z Newtonabc Rice Hub (IOI11_ricehub) C++14
0 / 100
5 ms 1972 KB
#include "ricehub.h"
#include<bits/stdc++.h>
using namespace std;
int besthub(int R, int L, int X[], long long B)
{
	const int N=1e5+10;
	long long qs[N];
	double tX[N];
	int mx=0;
	qs[0]=X[0];
	tX[0]=X[0];
	for(int i=1;i<R;i++) qs[i]=X[i]+qs[i-1],tX[i]=X[i];
	for(int i=0;i<R;i++){
		int l=i,r=R-1;
		while(l<r){
			int mid=(l+r+1)/2;
			long long sum=qs[mid],bg=0;
			if(i>0) sum-=qs[i-1];
			double mean=(double)sum/(double)(mid-i+1);
			int ind=lower_bound(tX+i,tX+mid+1,mean)-tX;
			if(ind-1>=0 && fabs(tX[ind]-mean)>fabs(tX[ind-1]-mean)) ind--;
			bg=(qs[mid]-qs[ind]-(X[ind]*(mid-ind)))+(X[ind]*(ind-i))-qs[ind-1];
			if(i>0) bg+=qs[i-1];
			if(bg<=B) l=mid;
			else r=mid-1;
		}
		mx=max(mx,l);
	}
	return mx;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1884 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1972 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1884 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 1884 KB Output isn't correct
2 Halted 0 ms 0 KB -