Submission #645085

#TimeUsernameProblemLanguageResultExecution timeMemory
645085andreast12K blocks (IZhO14_blocks)C++17
53 / 100
1 ms656 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define fi first #define se second const int mod=1e9+7, maxn=1e6+5;; int n, k, a[105], maxi; ll inf=1e18, dp[105][105]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> k; for(int i=0; i<=n; i++) for(int kel=0; kel<=k; kel++) dp[i][kel]=inf; dp[0][0]=0; for(int i=1; i<=n; i++) { cin >> a[i]; maxi=0; for(int j=i; j>0; j--) { maxi=max(maxi, a[j]); for(int kel=1; kel<=k; kel++) dp[i][kel]=min(dp[i][kel], dp[j-1][kel-1]+maxi); } } cout << dp[n][k] << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...