Submission #256833

# Submission time Handle Problem Language Result Execution time Memory
256833 2020-08-03T09:18:59 Z islingr Watching (JOI13_watching) C++17
100 / 100
176 ms 16508 KB
#include <bits/stdc++.h>
using namespace std;

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

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 + 1, a + n + 1);
	int l = 0, r = a[n];
	while (r - l > 1) {
		int w = l + (r - l + 1) / 2;
		for (int i = 1, j = 0, k = 0; i <= n; ++i) {
			while (w <= a[i] - a[j + 1]) ++j;
			while (2 * w <= a[i] - a[k + 1]) ++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]);
		}
		(dp[n][P] <= Q ? r : l) = w;
	}
	cout << r;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 768 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 288 KB Output is correct
5 Correct 1 ms 768 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 768 KB Output is correct
8 Correct 1 ms 768 KB Output is correct
9 Correct 1 ms 768 KB Output is correct
10 Correct 1 ms 768 KB Output is correct
11 Correct 1 ms 768 KB Output is correct
12 Correct 1 ms 768 KB Output is correct
13 Correct 1 ms 768 KB Output is correct
14 Correct 1 ms 768 KB Output is correct
15 Correct 1 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 8448 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 156 ms 16508 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 16 ms 8456 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 9 ms 8448 KB Output is correct
8 Correct 18 ms 8448 KB Output is correct
9 Correct 79 ms 16384 KB Output is correct
10 Correct 176 ms 16504 KB Output is correct
11 Correct 19 ms 8448 KB Output is correct
12 Correct 101 ms 16384 KB Output is correct
13 Correct 7 ms 8448 KB Output is correct
14 Correct 7 ms 8448 KB Output is correct
15 Correct 8 ms 8448 KB Output is correct