# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1031723 |
2024-07-23T05:42:18 Z |
juicy |
Watching (JOI13_watching) |
C++17 |
|
1 ms |
348 KB |
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
int main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
int N, P, Q; cin >> N >> P >> Q;
P = min(P, N);
Q = min(Q, N);
vector<int> A(N);
for (int i = 0; i < N; ++i) {
cin >> A[i];
}
vector dp(P + 1, vector<int>(Q + 1));
vector<array<int, 2>> nxt(N);
auto check = [&](int md) {
nxt[N - 1][0] = nxt[N - 1][1] = N - 1;
for (int i = N - 2; ~i; --i) {
for (int j = 1; j <= 2; ++j) {
int &p = nxt[i][j - 1];
p = nxt[i + 1][j - 1];
while (A[p] - A[i] >= j * md) {
--p;
}
}
}
for (int i = 0; i <= P; ++i) {
fill(dp[i].begin(), dp[i].end(), -1);
}
dp[0][0] = 0;
for (int i = 0; i <= P; ++i) {
for (int j = 0; j <= Q; ++j) {
if (dp[i][j] != -1) {
if (dp[i][j] == N) {
return true;
}
if (i + 1 <= P) {
dp[i + 1][j] = max(dp[i + 1][j], nxt[0][dp[i][j]] + 1);
}
if (j + 1 <= Q) {
dp[i][j + 1] = max(dp[i][j + 1], nxt[1][dp[i][j]] + 1);
}
}
}
}
return false;
};
int l = 0, r = 1e9, res = 1e9;
while (l <= r) {
int md = (l + r) / 2;
if (check(md)) {
res = md;
r = md - 1;
} else {
l = md + 1;
}
}
cout << res;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |