답안 #234958

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
234958 2020-05-26T12:43:14 Z Nodir_Bobiev 쌀 창고 (IOI11_ricehub) C++17
0 / 100
9 ms 896 KB
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;

int besthub(int R, int L, int X[], long long B)
{
	int ans = 0;
	long long sumL[R+2]={}, sumR[R+2]={};
	for( int i = 1; i <= R; i ++ ){
		sumL[i] = sumL[i-1] + X[i-1];
	}
	for( int i = R; i >= 1; i -- ){
		sumR[i] = sumR[i+1] + X[i-1];
	}
	int l = 1, r = 1;
	while( r <= R ){
		//cout << l << ' '<< r << endl;
		long long mid = (sumL[r]-sumL[l-1])/(r-l+1);
		int ll = l, rr = r+1;
		while( rr-ll>1 ){
			int mm=(ll+rr)>>1;
			if(X[mm-1]>mid)
				rr = mm;
			else
				ll = mm;
		}
		bool t = false;
		if( mid*1ll*(ll-l+1)-(sumL[ll]-sumL[l-1])+
			(sumR[ll]-sumR[r+1])-mid*1ll*(r-ll+1) <= B )
			t = true;
		if( (mid+1)*1ll*(ll-l+1)-(sumL[ll]-sumL[l-1])+
			(sumR[ll]-sumR[r+1])-(mid+1)*1ll*(r-ll+1) <= B )
			t = true;
		
		if( t ){
			ans = max(ans, r-l+1);
			r++;
		}
		else l ++;
	}
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Incorrect 5 ms 384 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB Output is correct
2 Incorrect 4 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 896 KB Output is correct
2 Incorrect 9 ms 896 KB Output isn't correct
3 Halted 0 ms 0 KB -