# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
170009 | WLZ | Watching (JOI13_watching) | C++14 | 653 ms | 16308 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int INF = 0x3f3f3f3f;
int n, p, q;
vector<int> a;
int check(int w) {
vector< vector<int> > dp(n + 1, vector<int>(min(n, p) + 1, INF));
dp[0][0] = 0;
int x = 0, y = 0;
for (int i = 0; i < n; i++) {
while (x < n && a[x] - a[i] + 1 <= w) {
x++;
}
while (y < n && a[y] - a[i] + 1 <= 2 * w) {
y++;
}
for (int j = 0; j < min(n, p); j++) {
dp[x][j + 1] = min(dp[x][j + 1], dp[i][j]);
dp[y][j] = min(dp[y][j], dp[i][j] + 1);
}
dp[y][min(n, p)] = min(dp[y][min(n, p)], dp[i][min(n, p)] + 1);
}
for (int i = 0; i <= min(n, p); i++) {
if (dp[n][i] <= q) {
return 1;
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |