Submission #256823

# Submission time Handle Problem Language Result Execution time Memory
256823 2020-08-03T09:00:25 Z islingr Watching (JOI13_watching) C++17
0 / 100
51 ms 8448 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 1 << 11;
int n, P, Q, a[N], dp[N][N];

bool f(int w) {
	dp[0][0] = 0;
	for (int i = 1; i <= n; ++i) {
		int j = i, k = i;
		while (j && a[i] - a[j] < w) --j;
		while (k && a[i] - a[k] < 2 * w) --k;
		dp[i][0] = 1 + dp[k][0];
		for (int p = 1; p <= P; ++p) dp[i][p] = min(dp[j][p - 1], 1 + dp[k][p]);
	}
	for (int p = 0; p <= P; ++p) if (dp[n][p] <= Q) return true;
	return false;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	cin >> n >> P >> Q;
	for (int i = 1; i <= n; ++i) cin >> a[i];
	if (n <= P) return cout << 1, 0;
	sort(a, a + n);
	int l = 0, r = a[n] - a[1] + 1;
	while (r - l > 1) {
		int m = l + (r - l + 1) / 2;
		(f(m) ? r : l) = m;
	}
	cout << r;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 768 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 51 ms 8448 KB Output isn't correct
2 Halted 0 ms 0 KB -