Submission #1075350

#TimeUsernameProblemLanguageResultExecution timeMemory
1075350South_CloudFeast (NOI19_feast)C++17
41 / 100
14 ms60500 KiB
#include<bits/stdc++.h> using namespace std; const int N = 2007; int n, K, a[N]; long long f[N][N][2], ans = 0; int main() { ios_base::sync_with_stdio(NULL); cin.tie(NULL); cin >> n >> K; for(int i = 1; i <= n; i++) { cin >> a[i]; } for(int i = 1; i <= n; i++) { for(int j = 0; j <= K; j++) { f[i][j][0] = max(f[i - 1][j][0], f[i - 1][j][1]); if(j > 0) f[i][j][1] = max(f[i - 1][j - 1][0], f[i - 1][j][1]) + a[i]; } } for(int i = 0; i <= K; i++) ans = max(ans, max(f[n][i][0], f[n][i][1])); cout << ans; 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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...