Submission #85554

#TimeUsernameProblemLanguageResultExecution timeMemory
85554KCSCWatching (JOI13_watching)C++14
0 / 100
399 ms14468 KiB
#include <bits/stdc++.h> using namespace std; const int DIM = 2005; int pos[DIM], pos1[DIM], pos2[DIM], dp[DIM][DIM]; int main(void) { #ifdef HOME freopen("watching.in", "r", stdin); freopen("watching.out", "w", stdout); #endif int n, p, q; cin >> n >> p >> q; for (int i = 1; i <= n; ++i) { cin >> pos[i]; } int le = 1, ri = 1000000000; while (le <= ri) { int md = (le + ri) / 2; for (int i = 1; i <= n; ++i) { pos1[i] = pos2[i] = 0; for (int j = 1; j < i; ++j) { if (pos[i] - md >= pos[j]) { pos1[i] = j; } if (pos[i] - md * 2 >= pos[j]) { pos2[i] = j; } } for (int j = 0; j <= i; ++j) { dp[i][j] = dp[pos2[i]][j] + 1; if (j > 0) { dp[i][j] = min(dp[i][j], dp[pos1[i]][j - 1]); } } } if (dp[n][min(n, p)] <= q) { ri = md - 1; } else { le = md + 1; } } cout << le; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...