Submission #51550

# Submission time Handle Problem Language Result Execution time Memory
51550 2018-06-18T14:01:03 Z PeppaPig Rice Hub (IOI11_ricehub) C++14
100 / 100
20 ms 16012 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;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 420 KB Output is correct
4 Correct 2 ms 420 KB Output is correct
5 Correct 2 ms 572 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 572 KB Output is correct
2 Correct 2 ms 696 KB Output is correct
3 Correct 2 ms 696 KB Output is correct
4 Correct 2 ms 696 KB Output is correct
5 Correct 2 ms 696 KB Output is correct
6 Correct 2 ms 696 KB Output is correct
7 Correct 2 ms 696 KB Output is correct
8 Correct 2 ms 696 KB Output is correct
9 Correct 2 ms 696 KB Output is correct
10 Correct 2 ms 696 KB Output is correct
11 Correct 2 ms 720 KB Output is correct
12 Correct 2 ms 720 KB Output is correct
13 Correct 2 ms 720 KB Output is correct
14 Correct 2 ms 748 KB Output is correct
15 Correct 2 ms 748 KB Output is correct
16 Correct 2 ms 748 KB Output is correct
17 Correct 2 ms 748 KB Output is correct
18 Correct 2 ms 748 KB Output is correct
19 Correct 2 ms 772 KB Output is correct
20 Correct 2 ms 776 KB Output is correct
21 Correct 2 ms 908 KB Output is correct
22 Correct 2 ms 924 KB Output is correct
23 Correct 2 ms 924 KB Output is correct
24 Correct 2 ms 924 KB Output is correct
25 Correct 2 ms 924 KB Output is correct
26 Correct 2 ms 924 KB Output is correct
27 Correct 2 ms 924 KB Output is correct
28 Correct 2 ms 924 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 924 KB Output is correct
2 Correct 2 ms 924 KB Output is correct
3 Correct 2 ms 924 KB Output is correct
4 Correct 2 ms 924 KB Output is correct
5 Correct 2 ms 924 KB Output is correct
6 Correct 2 ms 924 KB Output is correct
7 Correct 2 ms 924 KB Output is correct
8 Correct 2 ms 940 KB Output is correct
9 Correct 2 ms 940 KB Output is correct
10 Correct 2 ms 940 KB Output is correct
11 Correct 2 ms 956 KB Output is correct
12 Correct 2 ms 964 KB Output is correct
13 Correct 2 ms 964 KB Output is correct
14 Correct 2 ms 992 KB Output is correct
15 Correct 2 ms 1004 KB Output is correct
16 Correct 2 ms 1004 KB Output is correct
17 Correct 2 ms 1012 KB Output is correct
18 Correct 2 ms 1144 KB Output is correct
19 Correct 2 ms 1144 KB Output is correct
20 Correct 2 ms 1144 KB Output is correct
21 Correct 3 ms 1144 KB Output is correct
22 Correct 3 ms 1144 KB Output is correct
23 Correct 2 ms 1268 KB Output is correct
24 Correct 3 ms 1268 KB Output is correct
25 Correct 3 ms 1268 KB Output is correct
26 Correct 3 ms 1280 KB Output is correct
27 Correct 2 ms 1360 KB Output is correct
28 Correct 3 ms 1360 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1624 KB Output is correct
2 Correct 5 ms 1760 KB Output is correct
3 Correct 18 ms 3828 KB Output is correct
4 Correct 18 ms 4880 KB Output is correct
5 Correct 10 ms 4880 KB Output is correct
6 Correct 10 ms 5004 KB Output is correct
7 Correct 16 ms 6496 KB Output is correct
8 Correct 15 ms 7144 KB Output is correct
9 Correct 10 ms 7144 KB Output is correct
10 Correct 10 ms 7180 KB Output is correct
11 Correct 20 ms 8692 KB Output is correct
12 Correct 20 ms 9824 KB Output is correct
13 Correct 14 ms 9824 KB Output is correct
14 Correct 11 ms 10044 KB Output is correct
15 Correct 15 ms 11012 KB Output is correct
16 Correct 15 ms 11928 KB Output is correct
17 Correct 18 ms 13112 KB Output is correct
18 Correct 18 ms 13932 KB Output is correct
19 Correct 19 ms 15008 KB Output is correct
20 Correct 19 ms 16012 KB Output is correct