Submission #93093

#TimeUsernameProblemLanguageResultExecution timeMemory
93093Nodir_BobievK blocks (IZhO14_blocks)C++14
0 / 100
2 ms504 KiB
# include <iostream> using namespace std; const int N = 200; int n, k; int a[N]; long long dp[N][N]; int main() { ios_base::sync_with_stdio(false); cin >> n >> k; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= n; i++){ for (int j = 1; j <= k; j++){ dp[i][j] = 1e18; } } for (int i = 1; i <= n; i++){ for (int j = 1; j <= min(k, i); j++){ int mx = a[i]; for (int t = i - 1; t >= j - 1; t--){ dp[i][j] = min(dp[i][j], dp[t][j - 1] + mx); mx = max(mx, a[t]); } } } cout << dp[n][k]; } /* 5 1 1 2 3 4 5 5 5 1 2 3 4 5 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...