Submission #600237

# Submission time Handle Problem Language Result Execution time Memory
600237 2022-07-20T14:50:43 Z _Avocado_ Rice Hub (IOI11_ricehub) C++14
100 / 100
31 ms 3192 KB
#include <bits/stdc++.h>
#include "ricehub.h"
//#define int int64_t
using namespace std;

int bsearch(int n, int len, vector<int>&fred, vector<long long>&prefix, long long budget){
	int l = -1;
	int r = n+1;
	
	while(r-l > 1){
		int m = (r+l)/2;
		long long ans = 3e18;
		int mid = m/2+1;
		for(int i = m; i<=n; ++i){
			int hub = fred[mid];
			long long one = ((m/2) * hub)-(prefix[mid-1]-prefix[i-m]);
			long long two = (prefix[i]-prefix[mid-(1-m%2)]) - ((m/2)*hub);
			++mid;
			ans = min(ans, one+two);
		}
		if(ans <= budget) l = m;
		else r = m;

	}
	return l;
}
			

int besthub(int R, int L, int X[], long long B){
	int n = R;
	int len = L;
	long long budget = B;
	vector<long long>prefix(n+1);
	for(int i = 1; i<=n; ++i){
		prefix[i] = prefix[i-1] + X[i-1];
	}
	
	vector<int>fred;
	fred.push_back(0);
	for(int i = 0; i<n; ++i) fred.push_back(X[i]);
	
	return bsearch(n, len, fred, prefix, budget);
}

# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 2 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 2 ms 352 KB Output is correct
28 Correct 1 ms 452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 724 KB Output is correct
2 Correct 3 ms 724 KB Output is correct
3 Correct 14 ms 2128 KB Output is correct
4 Correct 18 ms 2128 KB Output is correct
5 Correct 11 ms 1552 KB Output is correct
6 Correct 9 ms 1620 KB Output is correct
7 Correct 24 ms 2804 KB Output is correct
8 Correct 15 ms 2920 KB Output is correct
9 Correct 12 ms 1492 KB Output is correct
10 Correct 7 ms 1492 KB Output is correct
11 Correct 20 ms 3192 KB Output is correct
12 Correct 16 ms 3136 KB Output is correct
13 Correct 10 ms 1632 KB Output is correct
14 Correct 8 ms 1620 KB Output is correct
15 Correct 11 ms 2592 KB Output is correct
16 Correct 22 ms 2492 KB Output is correct
17 Correct 15 ms 2828 KB Output is correct
18 Correct 14 ms 2896 KB Output is correct
19 Correct 14 ms 3036 KB Output is correct
20 Correct 31 ms 2980 KB Output is correct