Submission #285733

# Submission time Handle Problem Language Result Execution time Memory
285733 2020-08-29T14:08:26 Z peijar Rice Hub (IOI11_ricehub) C++17
100 / 100
24 ms 3328 KB
#include <bits/stdc++.h>
using namespace std;

#define SZ(v) ((int)(v).size())
using ll = long long;

const int MAXN = 1e5+1;

ll prefixSum[MAXN];
ll cntFields, maxCor, budget;
ll cor[MAXN];

ll getCost(int l, int r)
{
	int mid = (l+r)/2;
	ll cost = (2*mid-l-r) * cor[mid] + prefixSum[r+1] + prefixSum[l] - prefixSum[mid] - prefixSum[mid+1];
	return cost;
}

bool can(int want)
{
	for (int i(0); i + want <= cntFields; ++i)
		if (getCost(i, i+want-1) <= budget)
			return true;
	return false;
}

int besthub(int c, int m, int co[], ll b)
{
	budget = b;
	cntFields = c;
	maxCor = m;
	for (int i(0); i < cntFields; ++i)
		cor[i] = co[i];
	for (int i(0); i < cntFields; ++i)
		prefixSum[i+1] = prefixSum[i] + cor[i];

	int lo(0), up(cntFields);
	while (lo < up)
	{
		int mid = (lo+up+1)/2;
		if (can(mid)) lo = mid;
		else up = mid-1;
	}
	return lo;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 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
# Verdict Execution time Memory Grader output
1 Correct 1 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 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 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 1 ms 436 KB Output is correct
12 Correct 1 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 1 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 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 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 1 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 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 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 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 512 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 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 512 KB Output is correct
23 Correct 1 ms 512 KB Output is correct
24 Correct 1 ms 512 KB Output is correct
25 Correct 1 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 1 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 768 KB Output is correct
2 Correct 4 ms 896 KB Output is correct
3 Correct 18 ms 3320 KB Output is correct
4 Correct 18 ms 3328 KB Output is correct
5 Correct 9 ms 1664 KB Output is correct
6 Correct 12 ms 1664 KB Output is correct
7 Correct 16 ms 3064 KB Output is correct
8 Correct 16 ms 3072 KB Output is correct
9 Correct 11 ms 1664 KB Output is correct
10 Correct 9 ms 1536 KB Output is correct
11 Correct 24 ms 3328 KB Output is correct
12 Correct 20 ms 3320 KB Output is correct
13 Correct 10 ms 1664 KB Output is correct
14 Correct 10 ms 1664 KB Output is correct
15 Correct 15 ms 2560 KB Output is correct
16 Correct 16 ms 2560 KB Output is correct
17 Correct 18 ms 2944 KB Output is correct
18 Correct 18 ms 2944 KB Output is correct
19 Correct 19 ms 3200 KB Output is correct
20 Correct 19 ms 3200 KB Output is correct