Submission #105358

# Submission time Handle Problem Language Result Execution time Memory
105358 2019-04-11T14:08:27 Z CaQtiml Rice Hub (IOI11_ricehub) C++14
100 / 100
37 ms 1920 KB
#include "bits/stdc++.h"
#include "ricehub.h"
using namespace std;
#define ll long long
int a[100010];
ll qs[100010];
bool price(int st , int ed , ll budget)
{
	int mid = (st+ed)>>1;
	ll temp = a[mid]*((mid-st)-(ed-mid)) - qs[mid-1] + qs[st-1] + qs[ed] - qs[mid];
	//temp+=(qs[ed]-qs[mid-1])-1ll*a[mid]*(ed-mid+1);
	if(temp<=budget) return 1;
	else return 0;
}
int besthub(int n , int L , int X[] , ll budget)
{
	for(int i=1;i<=n;i++) 
	{
		a[i]=X[i-1];
		qs[i]=qs[i-1]+a[i];
	}
	int mx=-1;
	for(int i=1;i<=n;i++)
	{
		int st=i;
		int ed=n;
		while(st<=ed)
		{
			int mid = (st+ed)>>1;
			if(price(i,mid,budget)) st=mid+1;
			else ed=mid-1;
		}
		mx=max(mx,st-i);
	}
	return mx;
}
// int main()
// {
// 	int r , lim ,x[100010];
// 	ll bud;
// 	cin >> r >> lim >> bud ;
// 	for(int i=0;i<r;i++)
// 	{
// 		cin >>x[i];
// 	}
// 	//cin >> bud;
// 	cout << besthub(r,lim,x,bud);
// }
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 256 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 2 ms 256 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 3 ms 256 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
17 Correct 3 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 3 ms 384 KB Output is correct
21 Correct 2 ms 384 KB Output is correct
22 Correct 3 ms 384 KB Output is correct
23 Correct 2 ms 384 KB Output is correct
24 Correct 3 ms 384 KB Output is correct
25 Correct 2 ms 384 KB Output is correct
26 Correct 2 ms 384 KB Output is correct
27 Correct 2 ms 384 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 3 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 4 ms 384 KB Output is correct
22 Correct 4 ms 384 KB Output is correct
23 Correct 3 ms 384 KB Output is correct
24 Correct 3 ms 384 KB Output is correct
25 Correct 3 ms 384 KB Output is correct
26 Correct 4 ms 384 KB Output is correct
27 Correct 4 ms 384 KB Output is correct
28 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 640 KB Output is correct
2 Correct 6 ms 640 KB Output is correct
3 Correct 26 ms 1920 KB Output is correct
4 Correct 23 ms 1920 KB Output is correct
5 Correct 11 ms 1152 KB Output is correct
6 Correct 14 ms 1128 KB Output is correct
7 Correct 22 ms 1920 KB Output is correct
8 Correct 20 ms 1920 KB Output is correct
9 Correct 17 ms 1152 KB Output is correct
10 Correct 17 ms 1152 KB Output is correct
11 Correct 25 ms 1920 KB Output is correct
12 Correct 22 ms 1920 KB Output is correct
13 Correct 12 ms 1152 KB Output is correct
14 Correct 14 ms 1152 KB Output is correct
15 Correct 27 ms 1536 KB Output is correct
16 Correct 24 ms 1536 KB Output is correct
17 Correct 28 ms 1784 KB Output is correct
18 Correct 26 ms 1784 KB Output is correct
19 Correct 37 ms 1756 KB Output is correct
20 Correct 25 ms 1784 KB Output is correct