답안 #760618

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
760618 2023-06-18T03:19:28 Z SanguineChameleon 쌀 창고 (IOI11_ricehub) C++17
42 / 100
1000 ms 596 KB
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;

const int maxN = 1e5 + 20;
int a[maxN];
long long pref[maxN];

int besthub(int N, int L, int X[], long long B) {
	for (int i = 1; i <= N; i++) {
		a[i] = X[i - 1];
		pref[i] = pref[i - 1] + a[i];
	}
	int res = 0;
	for (int i = 1; i <= N; i++) {
		for (int j = i; j <= N; j++) {
			int mt = a[(i + j) / 2];
			long long sum = 0;
			for (int k = i; k <= j; k++) {
				sum += abs(a[k] - mt);
			}
			if (sum <= B) {
				res = max(res, j - i + 1);
			}
		}
	}
	return res;
	for (int i = 1; i <= N; i++) {
		int lt = 0;
		int rt = L;
		while (lt <= rt) {
			int mt = (lt + rt) / 2;
			int li = lower_bound(a + 1, a + N + 1, a[i] - mt) - a;
			int ri = upper_bound(a + 1, a + N + 1, a[i] + mt) - a - 1;
			long long cost_l = 1LL * a[i] * (i - li) - (pref[i - 1] - pref[li - 1]);
			long long cost_r = (pref[ri] - pref[i]) - 1LL * a[i] * (ri - i);
			if (cost_l + cost_r <= B) {
				res = max(res, ri - li + 1);
				lt = mt + 1;
			}
			else {
				rt = mt - 1;
			}
		}
	}
	return res;
}
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 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 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 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 0 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 17 ms 332 KB Output is correct
22 Correct 17 ms 324 KB Output is correct
23 Correct 17 ms 336 KB Output is correct
24 Correct 17 ms 340 KB Output is correct
25 Correct 17 ms 332 KB Output is correct
26 Correct 17 ms 336 KB Output is correct
27 Correct 18 ms 312 KB Output is correct
28 Correct 17 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 96 ms 212 KB Output is correct
4 Correct 103 ms 316 KB Output is correct
5 Correct 17 ms 324 KB Output is correct
6 Correct 17 ms 212 KB Output is correct
7 Correct 132 ms 212 KB Output is correct
8 Correct 131 ms 340 KB Output is correct
9 Correct 17 ms 212 KB Output is correct
10 Correct 18 ms 212 KB Output is correct
11 Correct 75 ms 212 KB Output is correct
12 Correct 69 ms 340 KB Output is correct
13 Correct 129 ms 340 KB Output is correct
14 Correct 129 ms 340 KB Output is correct
15 Correct 17 ms 340 KB Output is correct
16 Correct 17 ms 340 KB Output is correct
17 Correct 74 ms 320 KB Output is correct
18 Correct 67 ms 320 KB Output is correct
19 Correct 129 ms 212 KB Output is correct
20 Correct 128 ms 320 KB Output is correct
21 Execution timed out 1089 ms 340 KB Time limit exceeded
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1061 ms 596 KB Time limit exceeded
2 Halted 0 ms 0 KB -