제출 #412910

#제출 시각아이디문제언어결과실행 시간메모리
412910Tc14The short shank; Redemption (BOI21_prison)C++17
15 / 100
2079 ms8140 KiB
//#pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; #define ve vector typedef long long ll; typedef pair<int, int> pii; const int INF = 1e9 + 10; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, d, t; ve<int> T; ve<ve<int>> DP; cin >> n >> d >> t; T = ve<int>(n); DP = ve<ve<int>>(d + 1, ve<int>(n, INF)); for (int i = 0; i < n; i++) { cin >> T[i]; } DP[0][n - 1] = 0; for (int i = 1; i <= d; i++) { for (int j = n - 2; j >= 0; j--) { int z = INF; int cnt = 0; for (int k = j + 1; k < n; k++) { if (T[k] <= t || z <= t) cnt++; z = min(z, T[k]); z++; DP[i][j] = min(DP[i][j], DP[i - 1][k] + cnt); } } } int ans = INF; int z = INF; int cnt = 0; for (int i = 0; i < n; i++) { if (T[i] <= t || z <= t) cnt++; z = min(z, T[i]); z++; ans = min(ans, DP[d][i] + cnt); } cout << ans << endl; 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...