Submission #50946

# Submission time Handle Problem Language Result Execution time Memory
50946 2018-06-15T07:10:29 Z win11905 Rice Hub (IOI11_ricehub) C++11
100 / 100
33 ms 15996 KB
#include "ricehub.h"
#include <stdio.h>

const int N = 1e5+5;

long long pref[N];

int besthub(int R, int L, int X[], long long B) {
	for(int i = 0; i < R; ++i) pref[i+1] = pref[i] + X[i];
	auto f = [&](int l, int r, int m) {
		long long lhs = ((pref[m] - pref[m-1]) * (m-l)) - (pref[m-1] - pref[l-1]);
		long long rhs = (pref[r] - pref[m]) - ((pref[m] - pref[m-1]) * (r - m));
		return lhs + rhs <= B;
	};
	int l = 1, r = R;
	while(l < r) {
		int m = (l + r + 1) >> 1;
		bool st = false;
		for(int x = 1, y = m; y <= R; x++, y++) {
			int z = (x + y) >> 1;
			st |= f(x, y, z);
		}
		if(st) l = m;
		else r = m - 1;
	}
	return l;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 488 KB Output is correct
3 Correct 2 ms 488 KB Output is correct
4 Correct 2 ms 572 KB Output is correct
5 Correct 2 ms 588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 612 KB Output is correct
2 Correct 2 ms 784 KB Output is correct
3 Correct 2 ms 784 KB Output is correct
4 Correct 2 ms 784 KB Output is correct
5 Correct 2 ms 784 KB Output is correct
6 Correct 2 ms 784 KB Output is correct
7 Correct 2 ms 784 KB Output is correct
8 Correct 2 ms 784 KB Output is correct
9 Correct 2 ms 784 KB Output is correct
10 Correct 2 ms 784 KB Output is correct
11 Correct 2 ms 784 KB Output is correct
12 Correct 2 ms 784 KB Output is correct
13 Correct 2 ms 784 KB Output is correct
14 Correct 2 ms 784 KB Output is correct
15 Correct 2 ms 784 KB Output is correct
16 Correct 2 ms 784 KB Output is correct
17 Correct 2 ms 784 KB Output is correct
18 Correct 2 ms 784 KB Output is correct
19 Correct 2 ms 784 KB Output is correct
20 Correct 2 ms 784 KB Output is correct
21 Correct 2 ms 784 KB Output is correct
22 Correct 2 ms 784 KB Output is correct
23 Correct 2 ms 784 KB Output is correct
24 Correct 2 ms 784 KB Output is correct
25 Correct 2 ms 784 KB Output is correct
26 Correct 2 ms 784 KB Output is correct
27 Correct 2 ms 784 KB Output is correct
28 Correct 2 ms 784 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 784 KB Output is correct
2 Correct 2 ms 784 KB Output is correct
3 Correct 2 ms 864 KB Output is correct
4 Correct 2 ms 872 KB Output is correct
5 Correct 2 ms 872 KB Output is correct
6 Correct 2 ms 872 KB Output is correct
7 Correct 3 ms 904 KB Output is correct
8 Correct 4 ms 904 KB Output is correct
9 Correct 3 ms 912 KB Output is correct
10 Correct 2 ms 916 KB Output is correct
11 Correct 4 ms 928 KB Output is correct
12 Correct 2 ms 952 KB Output is correct
13 Correct 2 ms 956 KB Output is correct
14 Correct 2 ms 968 KB Output is correct
15 Correct 2 ms 968 KB Output is correct
16 Correct 2 ms 968 KB Output is correct
17 Correct 2 ms 1000 KB Output is correct
18 Correct 2 ms 1008 KB Output is correct
19 Correct 2 ms 1032 KB Output is correct
20 Correct 2 ms 1040 KB Output is correct
21 Correct 3 ms 1052 KB Output is correct
22 Correct 3 ms 1080 KB Output is correct
23 Correct 3 ms 1100 KB Output is correct
24 Correct 3 ms 1184 KB Output is correct
25 Correct 3 ms 1184 KB Output is correct
26 Correct 3 ms 1204 KB Output is correct
27 Correct 3 ms 1248 KB Output is correct
28 Correct 4 ms 1284 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1452 KB Output is correct
2 Correct 6 ms 1720 KB Output is correct
3 Correct 19 ms 3668 KB Output is correct
4 Correct 18 ms 4692 KB Output is correct
5 Correct 12 ms 4692 KB Output is correct
6 Correct 12 ms 4764 KB Output is correct
7 Correct 16 ms 6236 KB Output is correct
8 Correct 18 ms 6992 KB Output is correct
9 Correct 12 ms 6992 KB Output is correct
10 Correct 15 ms 6992 KB Output is correct
11 Correct 23 ms 8612 KB Output is correct
12 Correct 20 ms 9676 KB Output is correct
13 Correct 12 ms 9676 KB Output is correct
14 Correct 13 ms 9848 KB Output is correct
15 Correct 15 ms 10876 KB Output is correct
16 Correct 19 ms 11688 KB Output is correct
17 Correct 17 ms 12836 KB Output is correct
18 Correct 19 ms 13780 KB Output is correct
19 Correct 22 ms 14852 KB Output is correct
20 Correct 33 ms 15996 KB Output is correct