Submission #62983

# Submission time Handle Problem Language Result Execution time Memory
62983 2018-07-31T05:37:27 Z zetapi Rice Hub (IOI11_ricehub) C++14
68 / 100
1000 ms 3396 KB
#include "ricehub.h"

#include <bits/stdc++.h>
using namespace std;

#define pb  push_back
#define mp  make_pair
#define ll	long long
#define itr ::iterator 

typedef pair<int,int>  pii;

const int MAX=1e5;

int N,arr[MAX];

int cal(int ind,ll left)
{
	int pre=ind-1,nxt=ind,res=0;
	while(left>=0 and (pre>=0 or nxt<N))
	{
		if(pre<0 or (nxt<N and arr[ind]-arr[pre]>arr[nxt]-arr[ind]))
		{
			if(arr[nxt]-arr[ind]>left)
				break;
			left-=arr[nxt]-arr[ind];
			res++;
			nxt++;
		}
		else
		{
			if(arr[ind]-arr[pre]>left)
				break;
			left-=arr[ind]-arr[pre];
			res++;
			pre--;
		}
	}
	return res;
}

int besthub(int R, int L, int X[], long long B)
{
	int res=0;
	N=R;
	for(int A=0;A<N;A++)
		arr[A]=X[A];
	for(int A=0;A<N;A++)
		res=max(res,cal(A,B));
	return res;
}

/*signed main()
{
	ios_base::sync_with_stdio(false);

	int X[]={1,2,10,12,14};
	cout<<besthub(5,20,X,6);	
	return 0;
}*/
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 3 ms 488 KB Output is correct
3 Correct 3 ms 548 KB Output is correct
4 Correct 6 ms 548 KB Output is correct
5 Correct 3 ms 564 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 576 KB Output is correct
2 Correct 2 ms 628 KB Output is correct
3 Correct 3 ms 632 KB Output is correct
4 Correct 2 ms 636 KB Output is correct
5 Correct 4 ms 768 KB Output is correct
6 Correct 2 ms 768 KB Output is correct
7 Correct 4 ms 768 KB Output is correct
8 Correct 3 ms 828 KB Output is correct
9 Correct 3 ms 828 KB Output is correct
10 Correct 3 ms 828 KB Output is correct
11 Correct 2 ms 828 KB Output is correct
12 Correct 3 ms 828 KB Output is correct
13 Correct 2 ms 828 KB Output is correct
14 Correct 2 ms 828 KB Output is correct
15 Correct 3 ms 828 KB Output is correct
16 Correct 3 ms 828 KB Output is correct
17 Correct 3 ms 828 KB Output is correct
18 Correct 3 ms 828 KB Output is correct
19 Correct 3 ms 828 KB Output is correct
20 Correct 3 ms 832 KB Output is correct
21 Correct 4 ms 964 KB Output is correct
22 Correct 3 ms 964 KB Output is correct
23 Correct 3 ms 964 KB Output is correct
24 Correct 3 ms 964 KB Output is correct
25 Correct 4 ms 964 KB Output is correct
26 Correct 4 ms 964 KB Output is correct
27 Correct 3 ms 964 KB Output is correct
28 Correct 3 ms 964 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 964 KB Output is correct
2 Correct 3 ms 964 KB Output is correct
3 Correct 5 ms 964 KB Output is correct
4 Correct 4 ms 964 KB Output is correct
5 Correct 3 ms 964 KB Output is correct
6 Correct 2 ms 964 KB Output is correct
7 Correct 5 ms 964 KB Output is correct
8 Correct 3 ms 964 KB Output is correct
9 Correct 2 ms 964 KB Output is correct
10 Correct 3 ms 964 KB Output is correct
11 Correct 3 ms 972 KB Output is correct
12 Correct 4 ms 980 KB Output is correct
13 Correct 5 ms 980 KB Output is correct
14 Correct 5 ms 1012 KB Output is correct
15 Correct 4 ms 1020 KB Output is correct
16 Correct 3 ms 1024 KB Output is correct
17 Correct 7 ms 1024 KB Output is correct
18 Correct 8 ms 1036 KB Output is correct
19 Correct 9 ms 1036 KB Output is correct
20 Correct 10 ms 1052 KB Output is correct
21 Correct 7 ms 1060 KB Output is correct
22 Correct 8 ms 1084 KB Output is correct
23 Correct 92 ms 1108 KB Output is correct
24 Correct 80 ms 1140 KB Output is correct
25 Correct 160 ms 1248 KB Output is correct
26 Correct 158 ms 1248 KB Output is correct
27 Correct 42 ms 1380 KB Output is correct
28 Correct 44 ms 1380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 1716 KB Output is correct
2 Correct 13 ms 1856 KB Output is correct
3 Execution timed out 1063 ms 3396 KB Time limit exceeded
4 Halted 0 ms 0 KB -