Submission #105362

# Submission time Handle Problem Language Result Execution time Memory
105362 2019-04-11T14:24:13 Z CaQtiml Rice Hub (IOI11_ricehub) C++14
100 / 100
41 ms 2048 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;
	int save;
	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)) {save=mid; st=mid+1;}
			else ed=mid-1;
		}
		mx=max(mx,save-i+1);
	}
	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);
// }

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:34:17: warning: 'save' may be used uninitialized in this function [-Wmaybe-uninitialized]
   mx=max(mx,save-i+1);
             ~~~~^~
# 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 2 ms 384 KB Output is correct
5 Correct 2 ms 304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 2 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 2 ms 256 KB Output is correct
10 Correct 2 ms 256 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 3 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 2 ms 384 KB Output is correct
20 Correct 2 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 3 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 3 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 3 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 3 ms 356 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 2 ms 384 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 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 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 2 ms 384 KB Output is correct
19 Correct 3 ms 384 KB Output is correct
20 Correct 3 ms 384 KB Output is correct
21 Correct 3 ms 384 KB Output is correct
22 Correct 4 ms 384 KB Output is correct
23 Correct 4 ms 384 KB Output is correct
24 Correct 3 ms 384 KB Output is correct
25 Correct 4 ms 384 KB Output is correct
26 Correct 3 ms 384 KB Output is correct
27 Correct 4 ms 384 KB Output is correct
28 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 640 KB Output is correct
2 Correct 7 ms 640 KB Output is correct
3 Correct 41 ms 1912 KB Output is correct
4 Correct 25 ms 1868 KB Output is correct
5 Correct 13 ms 1152 KB Output is correct
6 Correct 11 ms 1152 KB Output is correct
7 Correct 22 ms 1920 KB Output is correct
8 Correct 22 ms 1920 KB Output is correct
9 Correct 15 ms 1152 KB Output is correct
10 Correct 11 ms 1152 KB Output is correct
11 Correct 22 ms 2048 KB Output is correct
12 Correct 28 ms 1912 KB Output is correct
13 Correct 13 ms 1152 KB Output is correct
14 Correct 13 ms 1036 KB Output is correct
15 Correct 20 ms 1536 KB Output is correct
16 Correct 21 ms 1536 KB Output is correct
17 Correct 24 ms 1792 KB Output is correct
18 Correct 23 ms 1784 KB Output is correct
19 Correct 24 ms 1792 KB Output is correct
20 Correct 22 ms 1824 KB Output is correct