답안 #364905

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
364905 2021-02-10T12:16:56 Z hoaphat1 쌀 창고 (IOI11_ricehub) C++17
100 / 100
21 ms 2668 KB
#include<bits/stdc++.h>
 
using namespace std;

int besthub(int n, int lim, int a[], long long b) {
	int l = 1, r = n;
	vector<long long> t(n);
	for (int i = 0; i < n; i++) {
		t[i] = a[i];
		if (i) t[i] += t[i-1];
	}
	auto getv = [&](int l, int r) {
		if (!l) return t[r];
		return t[r] - t[l-1];
	};
	auto test = [&](int num) {
		for (int i = 0; i + num <= n; i++) {
			auto get = [&](int n) {
				return -getv(i, i + n - 1) + getv(i + n, i + num - 1) - 1ll * a[i + n - 1] * (num - n - n);
			};
			if (min(get(num / 2), get((num + 1) / 2)) <= b) return true;
		}
		return false;
	};
	while (l <= r) {
		int mid = l + r >> 1;
		if (test(mid)) l = mid + 1;
		else r = mid - 1;
	}
	return r;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:26:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   26 |   int mid = l + r >> 1;
      |             ~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 2 ms 364 KB Output is correct
22 Correct 1 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 748 KB Output is correct
2 Correct 4 ms 748 KB Output is correct
3 Correct 15 ms 2540 KB Output is correct
4 Correct 15 ms 2540 KB Output is correct
5 Correct 8 ms 1260 KB Output is correct
6 Correct 8 ms 1260 KB Output is correct
7 Correct 13 ms 2284 KB Output is correct
8 Correct 13 ms 2284 KB Output is correct
9 Correct 8 ms 1260 KB Output is correct
10 Correct 8 ms 1260 KB Output is correct
11 Correct 15 ms 2540 KB Output is correct
12 Correct 21 ms 2668 KB Output is correct
13 Correct 9 ms 1260 KB Output is correct
14 Correct 9 ms 1260 KB Output is correct
15 Correct 11 ms 2028 KB Output is correct
16 Correct 15 ms 2028 KB Output is correct
17 Correct 13 ms 2284 KB Output is correct
18 Correct 13 ms 2284 KB Output is correct
19 Correct 14 ms 2412 KB Output is correct
20 Correct 14 ms 2412 KB Output is correct