Submission #255130

# Submission time Handle Problem Language Result Execution time Memory
255130 2020-07-31T10:04:47 Z babo Rice Hub (IOI11_ricehub) C++14
100 / 100
31 ms 3328 KB
#include <bits/stdc++.h>

using namespace std;

long long a[100010],nu[100010];
long long n,b;

bool ok(long long x){
	long long i;
	for(i=0;i<n-x+1;i++)
	{
		long long sum=0;
		long long s=i,e=i+x-1,mid=(s+e)/2;
		sum+=a[mid]*(mid-i+1)-(i==0?nu[mid]:(nu[mid]-nu[i-1]));
		sum+=(nu[e]-nu[mid])-a[mid]*(e-mid);
		if(sum<=b) return 1;
	}
	return 0;
}

int besthub(int R,int L,int *X,long long B){
	long long i;
	for(i=0;i<R;i++)
		a[i]=nu[i]=X[i];
	for(i=1;i<R;i++)
		nu[i]+=nu[i-1];
	n=R,b=B;
	long long s=1,e=R;
	while(s<e)
	{
		long long mid=(s+e+1)/2;
		if(ok(mid)) s=mid;
		else e=mid-1;
	}
	return (int)s;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 0 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 0 ms 384 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
19 Correct 0 ms 384 KB Output is correct
20 Correct 0 ms 384 KB Output is correct
21 Correct 0 ms 384 KB Output is correct
22 Correct 0 ms 384 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 0 ms 384 KB Output is correct
25 Correct 0 ms 384 KB Output is correct
26 Correct 0 ms 384 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 512 KB Output is correct
24 Correct 1 ms 512 KB Output is correct
25 Correct 2 ms 512 KB Output is correct
26 Correct 1 ms 512 KB Output is correct
27 Correct 1 ms 512 KB Output is correct
28 Correct 2 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 768 KB Output is correct
2 Correct 7 ms 896 KB Output is correct
3 Correct 26 ms 3328 KB Output is correct
4 Correct 19 ms 3328 KB Output is correct
5 Correct 9 ms 1664 KB Output is correct
6 Correct 9 ms 1664 KB Output is correct
7 Correct 14 ms 3072 KB Output is correct
8 Correct 14 ms 3072 KB Output is correct
9 Correct 12 ms 1664 KB Output is correct
10 Correct 8 ms 1664 KB Output is correct
11 Correct 31 ms 3320 KB Output is correct
12 Correct 18 ms 3328 KB Output is correct
13 Correct 9 ms 1664 KB Output is correct
14 Correct 9 ms 1664 KB Output is correct
15 Correct 14 ms 2560 KB Output is correct
16 Correct 13 ms 2560 KB Output is correct
17 Correct 17 ms 3072 KB Output is correct
18 Correct 16 ms 3072 KB Output is correct
19 Correct 17 ms 3200 KB Output is correct
20 Correct 17 ms 3200 KB Output is correct