답안 #655269

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
655269 2022-11-03T16:55:17 Z happypotato 쌀 창고 (IOI11_ricehub) C++17
100 / 100
17 ms 3256 KB
#include "ricehub.h"
using namespace std;
#define ll long long
const int mxN = 1e5 + 1;
ll int a[mxN], ps[mxN];
ll int budget;
int n;
bool test(int tar) {
	for (int i = (tar + 1) / 2; i <= n - tar / 2; i++) {
		ll int cur = 0;
		if (tar % 2 == 1) {
			cur += (a[i] * (tar / 2)) - (ps[i - 1] - ps[i - 1 - tar / 2]);
			cur += (ps[i + tar / 2] - ps[i]) - (a[i] * (tar / 2));
		} else {
			cur += (a[i] * (tar / 2)) - (ps[i] - ps[i - tar / 2]);
			cur += (ps[i + tar / 2] - ps[i]) - (a[i] * (tar / 2));
		}
		if (cur <= budget) return true;
	}
	return false;
}
int besthub(int R, int L, int X[], long long B) {
	n = R;
	for (int i = 1; i <= n; i++) {
		a[i] = X[i - 1];
		ps[i] = ps[i - 1] + a[i];
	}
	budget = B;
	int lb = 1, rb = n;
	while (lb < rb) {
		int mid = (lb + rb + 1) >> 1;
		if (test(mid)) lb = mid;
		else rb = mid - 1;
	}
	return lb;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 292 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 288 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 292 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 292 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 288 KB Output is correct
13 Correct 0 ms 296 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 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 0 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 0 ms 292 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 292 KB Output is correct
5 Correct 1 ms 288 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 296 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 292 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 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 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 304 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 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 432 KB Output is correct
27 Correct 1 ms 428 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 724 KB Output is correct
2 Correct 4 ms 800 KB Output is correct
3 Correct 17 ms 3256 KB Output is correct
4 Correct 17 ms 3236 KB Output is correct
5 Correct 6 ms 1620 KB Output is correct
6 Correct 6 ms 1588 KB Output is correct
7 Correct 13 ms 2928 KB Output is correct
8 Correct 12 ms 2900 KB Output is correct
9 Correct 7 ms 1492 KB Output is correct
10 Correct 7 ms 1572 KB Output is correct
11 Correct 15 ms 3232 KB Output is correct
12 Correct 15 ms 3228 KB Output is correct
13 Correct 7 ms 1620 KB Output is correct
14 Correct 7 ms 1616 KB Output is correct
15 Correct 11 ms 2480 KB Output is correct
16 Correct 11 ms 2476 KB Output is correct
17 Correct 12 ms 2900 KB Output is correct
18 Correct 12 ms 2876 KB Output is correct
19 Correct 13 ms 3096 KB Output is correct
20 Correct 14 ms 3120 KB Output is correct