Submission #259502

# Submission time Handle Problem Language Result Execution time Memory
259502 2020-08-07T23:39:24 Z amiratou Rice Hub (IOI11_ricehub) C++14
100 / 100
21 ms 2304 KB
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
 
ll cum[100005],tab[100005];
ll sum(int a,int b){
	if(a>b)return 0;
	return cum[b]-(a?cum[a-1]:0);
}
 
int besthub(int R, int L, int X[], long long B)
{
	for (int i = 0; i < R; ++i)
	{
		tab[i]=X[i];
		cum[i]=X[i];
		if(i)cum[i]+=cum[i-1];
	}
	int ans=1;
	for (int i = 0; i < R; ++i)
		for (int j = i+ans; j < R; ++j)
		{
			ll idx=i+(j-i)/2;
			ll nb_a=idx-i,nb_b=j-idx;
			ll cost=nb_a*X[idx]-sum(i,idx-1)+sum(idx+1,j)-nb_b*X[idx];
			if(cost<=B)ans=max(ans,j-i+1);
			else break;
		}
	return ans;
}
# 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 0 ms 384 KB Output is correct
5 Correct 0 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 1 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 1 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 1 ms 384 KB Output is correct
22 Correct 0 ms 384 KB Output is correct
23 Correct 0 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 0 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 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 0 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 1 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 1 ms 384 KB Output is correct
19 Correct 0 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 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 896 KB Output is correct
2 Correct 3 ms 768 KB Output is correct
3 Correct 18 ms 2304 KB Output is correct
4 Correct 17 ms 2300 KB Output is correct
5 Correct 10 ms 1280 KB Output is correct
6 Correct 7 ms 1280 KB Output is correct
7 Correct 15 ms 2304 KB Output is correct
8 Correct 16 ms 2304 KB Output is correct
9 Correct 7 ms 1280 KB Output is correct
10 Correct 7 ms 1280 KB Output is correct
11 Correct 19 ms 2304 KB Output is correct
12 Correct 21 ms 2304 KB Output is correct
13 Correct 8 ms 1280 KB Output is correct
14 Correct 8 ms 1280 KB Output is correct
15 Correct 14 ms 1792 KB Output is correct
16 Correct 14 ms 1792 KB Output is correct
17 Correct 17 ms 2048 KB Output is correct
18 Correct 17 ms 2048 KB Output is correct
19 Correct 18 ms 2168 KB Output is correct
20 Correct 18 ms 2176 KB Output is correct