Submission #311350

# Submission time Handle Problem Language Result Execution time Memory
311350 2020-10-10T00:47:08 Z LucaDantas Rice Hub (IOI11_ricehub) C++17
25 / 100
27 ms 2560 KB
#include "ricehub.h"
#include<algorithm>
#include<cstdio>

using ll = long long;

constexpr int maxn = 1e5+10;

ll pref[maxn];

inline ll itv(int l, int r) { return pref[r] - (l?pref[l-1]:0); }

ll cost(int l, int r, int a[]) {
	if(l == r) return 0;
	int m = (l+r) >> 1;
	int pos = a[m];
	ll cost = 1ll*pos*(m-l+1) - itv(l, m);
	cost += itv(m+1, r) - 1ll*pos*(r-m);
	return cost;
}

int besthub(int n, int l, int a[], ll b)
{
	int ans = 0;
	pref[0] = a[0];
	for(int i = 1; i < n; i++)
		pref[i] = pref[i-1]+a[i];
	for(int i = 0; i < n; i++) {
		int l = i, r = n, best = -1;
		while(l <= r) {
			int m = (l+r) >> 1;
			if(cost(i, m, a) <= b)
				best = m, l = m+1;
			else
				r = m-1;
		}
		ans = std::max(ans, best - i);
	}
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Incorrect 0 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 1 ms 416 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 0 ms 256 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 0 ms 256 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 0 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 0 ms 256 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 256 KB Output is correct
17 Correct 0 ms 256 KB Output is correct
18 Correct 0 ms 256 KB Output is correct
19 Correct 1 ms 256 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 256 KB Output is correct
22 Correct 0 ms 256 KB Output is correct
23 Correct 1 ms 256 KB Output is correct
24 Correct 1 ms 256 KB Output is correct
25 Correct 0 ms 256 KB Output is correct
26 Correct 1 ms 256 KB Output is correct
27 Correct 1 ms 256 KB Output is correct
28 Correct 0 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 360 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 1 ms 256 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Incorrect 0 ms 256 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 640 KB Output is correct
2 Correct 5 ms 640 KB Output is correct
3 Correct 25 ms 2552 KB Output is correct
4 Correct 25 ms 2560 KB Output is correct
5 Correct 11 ms 1280 KB Output is correct
6 Correct 11 ms 1280 KB Output is correct
7 Correct 22 ms 2304 KB Output is correct
8 Correct 23 ms 2304 KB Output is correct
9 Correct 11 ms 1152 KB Output is correct
10 Correct 11 ms 1152 KB Output is correct
11 Correct 27 ms 2560 KB Output is correct
12 Correct 26 ms 2552 KB Output is correct
13 Incorrect 11 ms 1280 KB Output isn't correct
14 Halted 0 ms 0 KB -