답안 #13707

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
13707 2015-03-16T11:14:31 Z progressive 쌀 창고 (IOI11_ricehub) C++
100 / 100
41 ms 6552 KB
#include "ricehub.h"
#define MAXN 100100
#include<algorithm>
using namespace std;

long long arr[MAXN];
long long sum[MAXN];

int besthub(int R, int L, int X[], long long B)
{
	sort(X,X+R);
	for(int i=0;i<R;i++) arr[i+1]=X[i];
	for(int i=1;i<=R;i++) sum[i]=sum[i-1]+arr[i];
	
	int ans=0;
	for(int i=1;i<=R;i++)
	{
		int lo=0; 
		int hi=min(R-i+1,i);
		while(lo+1!=hi)
		{
			int mi=(lo+hi)/2;
			long long C=sum[i+mi]-sum[i]-sum[i-1]+sum[i-mi-1];
			if(C<=B)
				lo=mi;
			else hi=mi;
		}
		ans=max(ans,2*lo+1);
	}
	for(int i=1;i<=R-1;i++)
	{
		int lo=-1;
		int hi=min(R-i,i);
		while(lo+1!=hi)
		{
			int mi=(lo+hi)/2;
			long long C=arr[i+1] - arr[i] + sum[i+mi+1] - sum[i+1] - sum[i-1] + sum[i-mi-1];
			if(C<=B)
				lo=mi;
			else hi=mi;
		}
		ans=max(ans,2*lo+2);
	}
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 6552 KB Output is correct
2 Correct 0 ms 6552 KB Output is correct
3 Correct 0 ms 6552 KB Output is correct
4 Correct 0 ms 6552 KB Output is correct
5 Correct 0 ms 6552 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 6552 KB Output is correct
2 Correct 0 ms 6552 KB Output is correct
3 Correct 0 ms 6552 KB Output is correct
4 Correct 0 ms 6552 KB Output is correct
5 Correct 0 ms 6552 KB Output is correct
6 Correct 0 ms 6552 KB Output is correct
7 Correct 0 ms 6552 KB Output is correct
8 Correct 0 ms 6552 KB Output is correct
9 Correct 0 ms 6552 KB Output is correct
10 Correct 0 ms 6552 KB Output is correct
11 Correct 0 ms 6552 KB Output is correct
12 Correct 0 ms 6552 KB Output is correct
13 Correct 0 ms 6552 KB Output is correct
14 Correct 0 ms 6552 KB Output is correct
15 Correct 0 ms 6552 KB Output is correct
16 Correct 0 ms 6552 KB Output is correct
17 Correct 0 ms 6552 KB Output is correct
18 Correct 0 ms 6552 KB Output is correct
19 Correct 0 ms 6552 KB Output is correct
20 Correct 0 ms 6552 KB Output is correct
21 Correct 0 ms 6552 KB Output is correct
22 Correct 0 ms 6552 KB Output is correct
23 Correct 0 ms 6552 KB Output is correct
24 Correct 0 ms 6552 KB Output is correct
25 Correct 0 ms 6552 KB Output is correct
26 Correct 0 ms 6552 KB Output is correct
27 Correct 0 ms 6552 KB Output is correct
28 Correct 0 ms 6552 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 6552 KB Output is correct
2 Correct 0 ms 6552 KB Output is correct
3 Correct 0 ms 6552 KB Output is correct
4 Correct 0 ms 6552 KB Output is correct
5 Correct 0 ms 6552 KB Output is correct
6 Correct 0 ms 6552 KB Output is correct
7 Correct 0 ms 6552 KB Output is correct
8 Correct 0 ms 6552 KB Output is correct
9 Correct 0 ms 6552 KB Output is correct
10 Correct 0 ms 6552 KB Output is correct
11 Correct 0 ms 6552 KB Output is correct
12 Correct 0 ms 6552 KB Output is correct
13 Correct 0 ms 6552 KB Output is correct
14 Correct 0 ms 6552 KB Output is correct
15 Correct 0 ms 6552 KB Output is correct
16 Correct 0 ms 6552 KB Output is correct
17 Correct 0 ms 6552 KB Output is correct
18 Correct 0 ms 6552 KB Output is correct
19 Correct 1 ms 6552 KB Output is correct
20 Correct 0 ms 6552 KB Output is correct
21 Correct 0 ms 6552 KB Output is correct
22 Correct 0 ms 6552 KB Output is correct
23 Correct 0 ms 6552 KB Output is correct
24 Correct 2 ms 6552 KB Output is correct
25 Correct 0 ms 6552 KB Output is correct
26 Correct 0 ms 6552 KB Output is correct
27 Correct 0 ms 6552 KB Output is correct
28 Correct 1 ms 6552 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 6552 KB Output is correct
2 Correct 4 ms 6552 KB Output is correct
3 Correct 41 ms 6552 KB Output is correct
4 Correct 31 ms 6552 KB Output is correct
5 Correct 15 ms 6552 KB Output is correct
6 Correct 15 ms 6552 KB Output is correct
7 Correct 23 ms 6552 KB Output is correct
8 Correct 29 ms 6552 KB Output is correct
9 Correct 17 ms 6552 KB Output is correct
10 Correct 13 ms 6552 KB Output is correct
11 Correct 34 ms 6552 KB Output is correct
12 Correct 37 ms 6552 KB Output is correct
13 Correct 13 ms 6552 KB Output is correct
14 Correct 21 ms 6552 KB Output is correct
15 Correct 29 ms 6552 KB Output is correct
16 Correct 30 ms 6552 KB Output is correct
17 Correct 35 ms 6552 KB Output is correct
18 Correct 35 ms 6552 KB Output is correct
19 Correct 25 ms 6552 KB Output is correct
20 Correct 29 ms 6552 KB Output is correct