Submission #753716

# Submission time Handle Problem Language Result Execution time Memory
753716 2023-06-05T18:21:03 Z nicksms Rice Hub (IOI11_ricehub) C++17
100 / 100
17 ms 3324 KB
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using db=long double;
template<class T> using V=vector<T>;
using vi = V<int>;
using vl = V<ll>;
using pi = pair<int,int>;
#define f first
#define s second
#define sz(x) (int)((x).size())

int besthub(int R, int L, int X[], ll B) {
	vl pre(R+1);
	vl x(R);
	for (int i = 0; i < R; i++) pre[i+1] = pre[i] + (x[i]=X[i]);
	int best = 1;
	int l = 0, r = 1;
	while (l < R) {
		r = max(l+1, r);
		while (r <= R) {
			int m = (l+r)/2;
			ll lo = pre[m]-pre[l];
			ll up = pre[r]-pre[m];
			lo = x[m]*(m-l) - lo;
			up -= x[m]*(r-m);
			if (lo + up <= B) {
				best = max(best, r-l);
				r += 1;
			} else break;
		}
		l++;
	}
	return best;
}
# 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 1 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 1 ms 312 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 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 308 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 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 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 1 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 1 ms 312 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 1 ms 212 KB Output is correct
4 Correct 1 ms 316 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 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 340 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 316 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 328 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 476 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 724 KB Output is correct
2 Correct 3 ms 852 KB Output is correct
3 Correct 12 ms 3284 KB Output is correct
4 Correct 12 ms 3240 KB Output is correct
5 Correct 6 ms 1620 KB Output is correct
6 Correct 6 ms 1620 KB Output is correct
7 Correct 17 ms 2972 KB Output is correct
8 Correct 12 ms 3008 KB Output is correct
9 Correct 5 ms 1568 KB Output is correct
10 Correct 6 ms 1596 KB Output is correct
11 Correct 13 ms 3324 KB Output is correct
12 Correct 12 ms 3244 KB Output is correct
13 Correct 6 ms 1652 KB Output is correct
14 Correct 6 ms 1620 KB Output is correct
15 Correct 10 ms 2476 KB Output is correct
16 Correct 10 ms 2480 KB Output is correct
17 Correct 11 ms 2892 KB Output is correct
18 Correct 12 ms 2880 KB Output is correct
19 Correct 12 ms 3116 KB Output is correct
20 Correct 12 ms 3108 KB Output is correct