Submission #875478

# Submission time Handle Problem Language Result Execution time Memory
875478 2023-11-19T21:00:41 Z StefanSebez Rice Hub (IOI11_ricehub) C++14
100 / 100
13 ms 5072 KB
#include "ricehub.h"
#include<bits/stdc++.h>
#define ll long long
int besthub(int n, int L, int X[], long long B)
{
	ll a[n+1];
	for(int i=1;i<=n;i++) a[i]=X[i-1];
	ll pref[n+1]={0};
	for(int i=1;i<=n;i++) pref[i]=pref[i-1]+a[i];
	int l=1,r=n,res=1;
	while(l<=r)
	{
		int mid=(l+r)/2;
		bool bul=false;
		for(int i=1;i+mid-1<=n;i++)
		{
			int j=(i+i+mid-1)/2;
			ll x=a[j]*(j-i)-(pref[j-1]-pref[i-1])+pref[i+mid-1]-pref[j]-a[j]*(i+mid-1-j);
			if(x<=B) bul=true;
			j++;
			x=a[j]*(j-i)-(pref[j-1]-pref[i-1])+pref[i+mid-1]-pref[j]-a[j]*(i+mid-1-j);
			if(x<=B) bul=true;

		}
		if(bul)
		{
			res=mid;
			l=mid+1;
		}
		else r=mid-1;
	}
	return res;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 560 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 600 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 344 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 600 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 476 KB Output is correct
22 Correct 1 ms 460 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 2 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 604 KB Output is correct
2 Correct 3 ms 604 KB Output is correct
3 Correct 13 ms 4216 KB Output is correct
4 Correct 10 ms 4188 KB Output is correct
5 Correct 7 ms 3300 KB Output is correct
6 Correct 7 ms 3420 KB Output is correct
7 Correct 9 ms 4216 KB Output is correct
8 Correct 11 ms 4188 KB Output is correct
9 Correct 7 ms 3420 KB Output is correct
10 Correct 7 ms 3420 KB Output is correct
11 Correct 10 ms 4208 KB Output is correct
12 Correct 10 ms 4184 KB Output is correct
13 Correct 8 ms 3420 KB Output is correct
14 Correct 9 ms 3676 KB Output is correct
15 Correct 12 ms 4444 KB Output is correct
16 Correct 8 ms 4440 KB Output is correct
17 Correct 9 ms 4956 KB Output is correct
18 Correct 9 ms 4956 KB Output is correct
19 Correct 10 ms 4948 KB Output is correct
20 Correct 11 ms 5072 KB Output is correct