Submission #1077263

#TimeUsernameProblemLanguageResultExecution timeMemory
1077263YudoTLEFeast (NOI19_feast)C++17
41 / 100
27 ms59472 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...