답안 #633969

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
633969 2022-08-23T14:29:12 Z MarcosPauloEvers 구경하기 (JOI13_watching) C++17
100 / 100
441 ms 31856 KB
#include <bits/stdc++.h>
#define int long long

#define CALC(X, w) \
	for (int i = 1; i <= n; i++) \
		for (X[i] = X[i - 1]; \
			 X[i] + 1 < i && pos[i] - pos[X[i] + 1] + 1 > (w); \
			 X[i]++);

using namespace std;

const int MAXN  = 2010;
int n, p, q;
int pos[MAXN];
int f[MAXN], g[MAXN];
int opt[MAXN][MAXN];

signed
main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	cin >> n >> p >> q;
	for (int i = 1; i <= n; i++)
		cin >> pos[i];

	sort(pos + 1, pos + 1 + n);

	int l = 1, r = 1000000000;
	while (l <= r) {
		int w = (l + r) >> 1;

		f[0] = g[0] = 0;
		opt[0][0] = 0;

		CALC(f, w);
		CALC(g, 2*w);

		for (int i = 1; i <= min(n, p); i++)
			for (opt[i][0] = opt[i - 1][0];
				 opt[i][0] < n && (f[opt[i][0] + 1] <= opt[i - 1][0]);
				 opt[i][0]++);

		for (int i = 1; i <= min(n, q); i++)
			for (opt[0][i] = opt[0][i - 1];
				 opt[0][i] < n && (g[opt[0][i] + 1] <= opt[0][i - 1]);
				 opt[0][i]++);

		for (int i = 1; i <= min(n, p); i++)
			for (int j = 1; j <= min(n, q); j++)
				for (opt[i][j] = max(opt[i][j - 1], opt[i - 1][j]);
					 opt[i][j] < n && (f[opt[i][j] + 1] <= opt[i - 1][j] || g[opt[i][j] + 1] <= opt[i][j - 1]);
					 opt[i][j]++);

		if (opt[min(n, p)][min(n, q)] < n) l = w + 1;
		else r = w - 1;
	}
	cout << l << "\n";
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 1 ms 724 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 2 ms 724 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 596 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 276 ms 23896 KB Output is correct
4 Correct 29 ms 9556 KB Output is correct
5 Correct 24 ms 1624 KB Output is correct
6 Correct 441 ms 31856 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 25 ms 1624 KB Output is correct
9 Correct 26 ms 4052 KB Output is correct
10 Correct 33 ms 9356 KB Output is correct
11 Correct 26 ms 1748 KB Output is correct
12 Correct 137 ms 11732 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 2 ms 468 KB Output is correct
15 Correct 2 ms 340 KB Output is correct