Submission #433126

# Submission time Handle Problem Language Result Execution time Memory
433126 2021-06-18T21:59:29 Z SuhaibSawalha1 Rice Hub (IOI11_ricehub) C++17
49 / 100
22 ms 2624 KB
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;

int besthub(int n, int L, int a[], long long B){
	int l = 0, r = 0, ans = 0;
	long long pref[n];
	for (int i = 0; i < n; ++i) {
		pref[i] = a[i];
		if (i) {
			pref[i] += pref[i - 1];
		}
	}
	auto get = [&] (int l, int r) {
		return pref[r] - (l ? pref[l - 1] : 0);
	};
	while (r < n) {
		int mid = (l + r) / 2;
		if ((mid - l + 1) * 1LL * a[mid] - get(l, mid) + get(mid + 1, r) - (r - mid) * 1LL * a[mid] < B) {
			ans = max(ans, r - l + 1);
			++r;
		}
		else {
			++l;
		}
	}
  return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Incorrect 1 ms 204 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 588 KB Output is correct
2 Correct 3 ms 588 KB Output is correct
3 Correct 18 ms 2464 KB Output is correct
4 Correct 22 ms 2624 KB Output is correct
5 Correct 7 ms 1228 KB Output is correct
6 Correct 8 ms 1236 KB Output is correct
7 Correct 14 ms 2424 KB Output is correct
8 Correct 14 ms 2124 KB Output is correct
9 Correct 7 ms 1084 KB Output is correct
10 Correct 7 ms 1100 KB Output is correct
11 Correct 16 ms 2524 KB Output is correct
12 Correct 16 ms 2508 KB Output is correct
13 Correct 7 ms 1260 KB Output is correct
14 Correct 7 ms 1228 KB Output is correct
15 Correct 12 ms 1868 KB Output is correct
16 Correct 12 ms 1932 KB Output is correct
17 Correct 14 ms 2184 KB Output is correct
18 Correct 14 ms 2244 KB Output is correct
19 Correct 15 ms 2380 KB Output is correct
20 Correct 15 ms 2380 KB Output is correct