Submission #1025635

#TimeUsernameProblemLanguageResultExecution timeMemory
1025635ZicrusFeast (NOI19_feast)C++17
59 / 100
174 ms262144 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll n, k; cin >> n >> k; vector<ll> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } vector<vector<ll>> dp(n, vector<ll>(k+1)); vector<vector<ll>> dpSeg(n, vector<ll>(k+1)); for (int j = 1; j <= k; j++) { dpSeg[0][j] = max(0ll, a[0]); } for (int i = 1; i < n; i++) { for (int j = 1; j <= k; j++) { dp[i][j] = max(dp[i-1][j], dpSeg[i-1][j]); dpSeg[i][j] = max(dp[i-1][j-1], dpSeg[i-1][j]) + a[i]; } } cout << max(dp.back().back(), dpSeg.back().back()); }
#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...