Submission #697298

#TimeUsernameProblemLanguageResultExecution timeMemory
697298Dan4LifeThe short shank; Redemption (BOI21_prison)C++17
0 / 100
257 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]; dp[1][1] = a[1]<=T; for(int i = 1; i <= n; i++){ int ans = 0, mn = LINF; for(int j = i; j <= n; j++){ ans+=(min(mn+1,a[j])<=T); calc[i][j] = ans; mn = min(mn+1, a[j+1]); } } for(int i = 2; i <= n; i++) for(int j = 1; 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...