Submission #1094221

#TimeUsernameProblemLanguageResultExecution timeMemory
1094221Trisanu_DasFeast (NOI19_feast)C++17
21 / 100
1098 ms24660 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int dp[2005][2005]; signed main(){ ios_base::sync_with_stdio(false); cin.tie(0); int n, k; cin >> n >> k; int a[n + 1]; for(int i = 1; i <= n; i++) cin >> a[i]; for(int i = 1; i <= n; i++) a[i] += a[i - 1]; for(int i = 1; i <= n; i++){ for(int j = 1; j <= k; j++){ dp[i][j] = max(dp[i][j], dp[i - 1][j]); for(int l = 0; l < i; l++) dp[i][j] = max(dp[i][j], dp[l][j - 1] + a[i] - a[l]); } } cout << dp[n][k]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...