제출 #845721

#제출 시각아이디문제언어결과실행 시간메모리
845721BamshooTK blocks (IZhO14_blocks)C++14
53 / 100
7 ms43256 KiB
#include <iostream> #include <cstring> #include <vector> #define ll long long #define FOR(i, a, b) for (int i = (a); i <= (b); ++i) #define fi first #define se second #define inf 1e18 using namespace std; typedef pair <int, int> ii; const int N = 1e5 + 9; int n, k, a[N], dp[N][109]; int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); // freopen("nhap.inp", "r", stdin); // freopen("xuat.out", "w", stdout); cin >> n >> k; FOR(i, 1, n) cin >> a[i]; if (n > 100) return 0; memset(dp, 0x3f, sizeof dp); dp[0][0] = 0; FOR(t, 1, k) for (int i = t; i <= n; ++i) { int p = a[i]; for (int j = i; j > 0; --j) { p = max(p, a[j]); dp[t][i] = min(dp[t][i], dp[t-1][j-1] +p); } } cout << dp[k][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...