Submission #133125

# Submission time Handle Problem Language Result Execution time Memory
133125 2019-07-20T07:46:52 Z zozder Rice Hub (IOI11_ricehub) C++14
17 / 100
1000 ms 1528 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=(x[l]+x[r])/2;//倉之位置
//		cout<<l<<","<<r<<","<<mid<<"\t";
		long long count;
		count=0;
//		cout<<count<<",";
		for(int i=l;i<=r;i++)if(x[i]<mid)count+=mid-x[i];
		else count+=x[i]-mid;
//		cout<<count<<endl;
		if(count<=B)
		{
			if(ans==-1||r-l+1>ans)ans=r-l+1;
			r++;
		}
		else l++;
		if(l>r)r++;
	}
	
	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 252 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 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 256 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 Incorrect 2 ms 380 KB Output isn't correct
28 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Incorrect 2 ms 376 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 632 KB Output is correct
2 Correct 5 ms 504 KB Output is correct
3 Execution timed out 1077 ms 1528 KB Time limit exceeded
4 Halted 0 ms 0 KB -