제출 #1179850

#제출 시각아이디문제언어결과실행 시간메모리
1179850altern23K개의 묶음 (IZhO14_blocks)C++17
0 / 100
0 ms328 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pii pair<ll, ll> #define fi first #define sec second #define ld long double const int MAXN = 1e6; const ll INF = 4e18; const int MOD = 998244353; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int tc = 1; // cin >> tc; for(;tc--;){ ll N, K; cin >> N >> K; vector<vector<ll>> dp(N + 5, vector<ll>(K + 5, INF)); vector<ll> a(N + 5); dp[0][0] = 0; for(int i = 1; i <= N; i++){ cin >> a[i]; ll cur = a[i]; for(int j = 1; j <= K; j++){ for(int k = i; k >= 1; --k){ cur = max(cur, a[k]); dp[i][j] = min(dp[i][j], dp[k - 1][j - 1] + cur); } } } cout << dp[N][K] << "\n"; } } /* 1 2 3 4 5 6 7 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...