Submission #1019262

#TimeUsernameProblemLanguageResultExecution timeMemory
1019262NicolaikrobFeast (NOI19_feast)C++17
21 / 100
1061 ms262144 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { int n, k; cin >> n >> k; ll A[n+1], DP[n+2][k+2]; A[0] = 0; for(int i = 1; i <= n; i++) cin >> A[i]; for(int i = 0; i < n+2; i++) DP[i][0] = 0; for(int i = 0; i < k+2; i++) DP[0][i] = 0; for(int i = 1; i <= n; i++) { for(int j = 1; j <= k; j++) { DP[i][j] = DP[i-1][j]; ll ns = A[i]; for(int l = i-1; l >= 0; l--) { DP[i][j] = max(DP[i][j], DP[l][j-1]+ns); ns += 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...