답안 #83413

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
83413 2018-11-07T13:47:05 Z Tusk 쌀 창고 (IOI11_ricehub) C++14
100 / 100
26 ms 16124 KB
#include "ricehub.h"
#include <bits/stdc++.h>

using namespace std;

long long min(long long a,int b) {return a<b?a:b;}  

int besthub(int R, int L, int X[], long long B)
{
	long long qs[R];
	qs[0]=X[0];
	for(int i=1;i<R;i++) qs[i]=(qs[i-1]+X[i]);
	int l=0,r=R;
	int ret = 0;
	while(l<=r) {
		int mid=(l+r)>>1;
		int wm=mid>>1;
		long long mn = LLONG_MAX;
		for(int i=0;i<R-mid+1;i++) {
			if(mid==1) mn=min(mn,0);
			else if(mid==2) mn=min(mn,X[i+wm]-X[i+wm-1]);
			else {
				long long cost;
				if(mid&1) cost=qs[i+mid-1]-qs[i+wm]-qs[i+wm-1]+(i>0?qs[i-1]:0);
				else cost=qs[i+mid-1]-qs[i+wm]-qs[i+wm-1]+(i>0?qs[i-1]:0)+X[i+wm];
				mn=min(mn,cost);
			}
		}
		if(mn<=B) {
			ret=mid;
			l=mid+1;
		} else {
			r=mid-1;
		}
	}

	return ret;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 2 ms 580 KB Output is correct
4 Correct 2 ms 580 KB Output is correct
5 Correct 2 ms 580 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 756 KB Output is correct
2 Correct 2 ms 756 KB Output is correct
3 Correct 2 ms 756 KB Output is correct
4 Correct 2 ms 768 KB Output is correct
5 Correct 2 ms 768 KB Output is correct
6 Correct 3 ms 768 KB Output is correct
7 Correct 2 ms 768 KB Output is correct
8 Correct 2 ms 768 KB Output is correct
9 Correct 2 ms 768 KB Output is correct
10 Correct 3 ms 768 KB Output is correct
11 Correct 2 ms 816 KB Output is correct
12 Correct 2 ms 816 KB Output is correct
13 Correct 2 ms 864 KB Output is correct
14 Correct 2 ms 864 KB Output is correct
15 Correct 2 ms 864 KB Output is correct
16 Correct 2 ms 864 KB Output is correct
17 Correct 2 ms 896 KB Output is correct
18 Correct 2 ms 896 KB Output is correct
19 Correct 2 ms 896 KB Output is correct
20 Correct 2 ms 896 KB Output is correct
21 Correct 2 ms 912 KB Output is correct
22 Correct 3 ms 916 KB Output is correct
23 Correct 2 ms 920 KB Output is correct
24 Correct 2 ms 924 KB Output is correct
25 Correct 2 ms 924 KB Output is correct
26 Correct 3 ms 932 KB Output is correct
27 Correct 3 ms 932 KB Output is correct
28 Correct 2 ms 932 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 944 KB Output is correct
2 Correct 2 ms 944 KB Output is correct
3 Correct 2 ms 952 KB Output is correct
4 Correct 2 ms 960 KB Output is correct
5 Correct 2 ms 1024 KB Output is correct
6 Correct 2 ms 1024 KB Output is correct
7 Correct 2 ms 1032 KB Output is correct
8 Correct 2 ms 1060 KB Output is correct
9 Correct 2 ms 1068 KB Output is correct
10 Correct 2 ms 1068 KB Output is correct
11 Correct 2 ms 1088 KB Output is correct
12 Correct 2 ms 1112 KB Output is correct
13 Correct 3 ms 1120 KB Output is correct
14 Correct 2 ms 1128 KB Output is correct
15 Correct 2 ms 1128 KB Output is correct
16 Correct 2 ms 1140 KB Output is correct
17 Correct 2 ms 1144 KB Output is correct
18 Correct 2 ms 1152 KB Output is correct
19 Correct 2 ms 1160 KB Output is correct
20 Correct 2 ms 1160 KB Output is correct
21 Correct 3 ms 1176 KB Output is correct
22 Correct 3 ms 1200 KB Output is correct
23 Correct 3 ms 1224 KB Output is correct
24 Correct 3 ms 1256 KB Output is correct
25 Correct 3 ms 1288 KB Output is correct
26 Correct 3 ms 1328 KB Output is correct
27 Correct 4 ms 1368 KB Output is correct
28 Correct 3 ms 1408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1704 KB Output is correct
2 Correct 5 ms 1840 KB Output is correct
3 Correct 17 ms 3924 KB Output is correct
4 Correct 26 ms 4964 KB Output is correct
5 Correct 16 ms 4964 KB Output is correct
6 Correct 10 ms 5092 KB Output is correct
7 Correct 18 ms 6452 KB Output is correct
8 Correct 16 ms 7224 KB Output is correct
9 Correct 9 ms 7224 KB Output is correct
10 Correct 10 ms 7224 KB Output is correct
11 Correct 21 ms 8828 KB Output is correct
12 Correct 20 ms 9892 KB Output is correct
13 Correct 15 ms 9892 KB Output is correct
14 Correct 14 ms 10084 KB Output is correct
15 Correct 18 ms 11112 KB Output is correct
16 Correct 15 ms 11900 KB Output is correct
17 Correct 23 ms 13072 KB Output is correct
18 Correct 17 ms 14016 KB Output is correct
19 Correct 19 ms 15088 KB Output is correct
20 Correct 21 ms 16124 KB Output is correct