# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
405968 | Halogen | The short shank; Redemption (BOI21_prison) | C++14 | 1 ms | 204 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 <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> ii;
int N, D, T;
int A[2000005];
main() {
scanf("%lld %lld %lld", &N, &D, &T);
for (int i = 1; i <= N; i++) scanf("%lld", &A[i]);
ii dp[N + 5][D + 5];
for (int i = 1; i <= N; i++) {
for (int j = 1; j < D; j++) {
ii use = dp[i - 1][j + 1];
use.second = A[i];
if (A[i] <= T) use.first++;
ii unuse = dp[i - 1][j];
unuse.second++;
if (unuse.second <= T) unuse.first++;
if (use.first == unuse.first) {
if (use.second > unuse.second) dp[i][j] = use;
else dp[i][j] = unuse;
}
else if (use.first < unuse.first) dp[i][j] = use;
else dp[i][j] = unuse;
}
}
int ans = N;
for (int i = 0; i < D; i++) {
ans = min(ans, dp[N - 1][i].second);
}
printf("%d", ans);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |