Submission #93342

#TimeUsernameProblemLanguageResultExecution timeMemory
93342RAkhshonK blocks (IZhO14_blocks)C++14
53 / 100
1069 ms552 KiB
#include<bits/stdc++.h> #define ll long long #define fr first #define se second #define ios ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL); using namespace std; ll a[101101], dp[111][111]; int main(){ ///freopen("A.in", "r", stdin); ///freopen("A.out", "w", stdout); ios; ll n, m; cin>>n>>m; for(ll i = 1; i <= n; i ++){ cin>>a[i]; } for(ll i = 1; i <= n; i ++){ dp[1][i]=max(dp[1][i-1],a[i]); } for(ll k = 2; k <= m; k ++){ for(ll i = k; i <= n; i ++){ ll mx = a[i]; dp[k][i]=dp[k-1][i-1]+mx; for(ll j = i; j >= k; j --){ mx=max(mx,a[j]); dp[k][i]=min(dp[k][i],dp[k-1][j-1]+mx); } ///cout<<dp[k][i]<<' '; } } ///cout<<endl; cout<<dp[m][n]; 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...