답안 #418350

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
418350 2021-06-05T10:06:49 Z Azimjon 쌀 창고 (IOI11_ricehub) C++17
68 / 100
1000 ms 3012 KB
#include "ricehub.h"
#include <bits/stdc++.h>

using namespace std;

int besthub(int R, int L, int X[], long long B) {
	auto cost = [&](int x, int y) { return abs(X[x] - X[y]); };

	int ans = 1;
	int pb = 0;
	int l, r;
	l = r = 0;

	for (; l + 1 < R;) {
		while (r + 1 < R) {
			int lm = (l + r) / 2;
			int cm = (l + r + 1) / 2;
			int cb = pb;

			if (lm != cm) {
				cb += (lm - l + 1) * cost(cm, lm);
				cb -= (r - cm + 1) * cost(cm, lm);
			}

			cb += cost(cm, r + 1);
			cerr << l << " " << r + 1 << " " << cb << " " << endl;
			if (cb > B)
				break;
			pb = cb;

			r++;
		}

		ans = max(ans, r - l + 1);

		// l++;
		int lm = (l + r) / 2;
		int cm = (l + r + 1) / 2;

		if (lm != cm) {
			pb += (lm - l + 1) * cost(cm, lm);
			pb -= (r - cm + 1) * cost(cm, lm);
		}
		pb -= cost(cm, l);
		l++;
		r = max(r, l);
		cerr << "-----" << l << " " << r << " " << pb << " " << endl;
	}

	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 3 ms 300 KB Output is correct
5 Correct 3 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 3 ms 204 KB Output is correct
6 Correct 3 ms 204 KB Output is correct
7 Correct 3 ms 204 KB Output is correct
8 Correct 3 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 300 KB Output is correct
11 Correct 2 ms 296 KB Output is correct
12 Correct 2 ms 204 KB Output is correct
13 Correct 2 ms 300 KB Output is correct
14 Correct 2 ms 204 KB Output is correct
15 Correct 3 ms 292 KB Output is correct
16 Correct 3 ms 204 KB Output is correct
17 Correct 2 ms 204 KB Output is correct
18 Correct 2 ms 204 KB Output is correct
19 Correct 5 ms 300 KB Output is correct
20 Correct 3 ms 204 KB Output is correct
21 Correct 17 ms 308 KB Output is correct
22 Correct 17 ms 332 KB Output is correct
23 Correct 13 ms 312 KB Output is correct
24 Correct 14 ms 332 KB Output is correct
25 Correct 14 ms 312 KB Output is correct
26 Correct 13 ms 332 KB Output is correct
27 Correct 15 ms 316 KB Output is correct
28 Correct 16 ms 324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 204 KB Output is correct
2 Correct 6 ms 204 KB Output is correct
3 Correct 21 ms 348 KB Output is correct
4 Correct 22 ms 332 KB Output is correct
5 Correct 16 ms 316 KB Output is correct
6 Correct 17 ms 204 KB Output is correct
7 Correct 34 ms 316 KB Output is correct
8 Correct 33 ms 332 KB Output is correct
9 Correct 16 ms 332 KB Output is correct
10 Correct 16 ms 324 KB Output is correct
11 Correct 26 ms 324 KB Output is correct
12 Correct 26 ms 328 KB Output is correct
13 Correct 24 ms 320 KB Output is correct
14 Correct 24 ms 348 KB Output is correct
15 Correct 15 ms 332 KB Output is correct
16 Correct 16 ms 316 KB Output is correct
17 Correct 19 ms 316 KB Output is correct
18 Correct 19 ms 204 KB Output is correct
19 Correct 24 ms 332 KB Output is correct
20 Correct 24 ms 336 KB Output is correct
21 Correct 170 ms 520 KB Output is correct
22 Correct 171 ms 604 KB Output is correct
23 Correct 116 ms 476 KB Output is correct
24 Correct 117 ms 452 KB Output is correct
25 Correct 115 ms 596 KB Output is correct
26 Correct 115 ms 520 KB Output is correct
27 Correct 135 ms 576 KB Output is correct
28 Correct 136 ms 580 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 677 ms 1604 KB Output is correct
2 Correct 677 ms 1696 KB Output is correct
3 Execution timed out 1089 ms 3012 KB Time limit exceeded
4 Halted 0 ms 0 KB -