Submission #133139

# Submission time Handle Problem Language Result Execution time Memory
133139 2019-07-20T07:55:47 Z zozder Rice Hub (IOI11_ricehub) C++14
100 / 100
19 ms 2556 KB
#include "ricehub.h"
#include <iostream>
#include <cstdlib>
#define maxrice 100005
using namespace std;

long long sum[maxrice],l,r,ans;

int besthub(int R, int L, int x[], long long B)
{
	for(int i=0;i<R;i++)sum[i]=x[i];
	for(int i=0;i<R-1;i++)sum[i+1]+=sum[i];
//	for(int i=0;i<R;i++)cout<<x[i]<<"\t";cout<<endl;
//	for(int i=0;i<R;i++)cout<<sum[i]<<"\t";cout<<endl;
	
	l=0;r=0;ans=-1;
	while(l<R&&r<R)
	{
		long long mid=(l+r)/2;//倉之位置
		long long count;
		count = x[mid]*(mid-l) - sum[mid-1] + sum[l-1] + sum[r] - sum[mid] - x[mid]*(r-mid);
		if(count<=B)
		{
			if(r-l+1>ans)ans=r-l+1;
			r++;
		}
		else l++;
	}
	
	return ans;
}
# 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 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
# 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 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
# 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 372 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 380 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 380 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 3 ms 376 KB Output is correct
23 Correct 3 ms 504 KB Output is correct
24 Correct 3 ms 376 KB Output is correct
25 Correct 3 ms 376 KB Output is correct
26 Correct 3 ms 376 KB Output is correct
27 Correct 3 ms 376 KB Output is correct
28 Correct 3 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 632 KB Output is correct
2 Correct 5 ms 632 KB Output is correct
3 Correct 18 ms 2552 KB Output is correct
4 Correct 18 ms 2552 KB Output is correct
5 Correct 9 ms 1272 KB Output is correct
6 Correct 8 ms 1272 KB Output is correct
7 Correct 15 ms 2296 KB Output is correct
8 Correct 15 ms 2296 KB Output is correct
9 Correct 8 ms 1144 KB Output is correct
10 Correct 8 ms 1148 KB Output is correct
11 Correct 19 ms 2556 KB Output is correct
12 Correct 19 ms 2552 KB Output is correct
13 Correct 9 ms 1276 KB Output is correct
14 Correct 10 ms 1244 KB Output is correct
15 Correct 15 ms 1932 KB Output is correct
16 Correct 15 ms 1912 KB Output is correct
17 Correct 18 ms 2344 KB Output is correct
18 Correct 18 ms 2296 KB Output is correct
19 Correct 19 ms 2380 KB Output is correct
20 Correct 19 ms 2396 KB Output is correct