Submission #697300

#TimeUsernameProblemLanguageResultExecution timeMemory
697300Dan4LifeThe short shank; Redemption (BOI21_prison)C++17
15 / 100
2093 ms524288 KiB
#include <bits/stdc++.h> using namespace std; #define fi first #define se second #define pb push_back #define mp make_pair #define int long long #define sz(a) (int)a.size() #define all(a) a.begin(),a.end() const int mxN = (int)1e5+10; const int LINF = (int)1e18; int n, k, T, a[mxN]; vector<vector<int>> dp,calc; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n >> k >> T; k++; calc.resize(n+2,vector<int>(n+2,0)); dp.resize(n+2,vector<int>(k+2,LINF)); for(int i = 1; i <= n; i++) cin >> a[i]; for(int i = 1; i <= n; i++){ int ans = 0, mn = a[i]; for(int j = i; j <= n; j++){ mn = min(mn+1, a[j]); ans+=(mn<=T); calc[i][j] = ans; if(i==1) dp[j][1] = ans; } } for(int i = 2; i <= n; i++) for(int j = 2; j <= k; j++) for(int x = 1; x < i; x++) dp[i][j] = min(dp[i][j],dp[x][j-1]+calc[x+1][i]); cout << dp[n][k]; }
#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...