제출 #532374

#제출 시각아이디문제언어결과실행 시간메모리
5323744fectaThe short shank; Redemption (BOI21_prison)C++17
15 / 100
2101 ms203588 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define int ll #define ld long double #define pii pair<int, int> #define f first #define s second #define boost() cin.tie(0), cin.sync_with_stdio(0) const int MN = 4005; int n, d, T, t[MN], cnt[MN][MN], dp[MN][MN]; int32_t main() { boost(); cin >> n >> d >> T; for (int i = 1; i <= n; i++) cin >> t[i]; for (int i = 1; i <= n; i++) { int num = 0, mn = 0x3f3f3f3f; for (int j = i; j <= n; j++) { if (min(mn, t[j]) <= T) num++; cnt[i][j] = num; mn = min(mn, t[j]) + 1; } } memset(dp, 0x3f, sizeof(dp)); dp[0][0] = 0; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { for (int k = 1; k <= i; k++) { dp[i][j] = min(dp[i][j], dp[k - 1][j - 1] + cnt[k][i]); } } } printf("%lld\n", dp[n][d + 1]); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...