제출 #1207653

#제출 시각아이디문제언어결과실행 시간메모리
1207653AmadooFeast (NOI19_feast)C++20
0 / 100
1 ms584 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int N = 2e3 + 5; int a[N], dp[N][N], pre[N]; signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n, k; cin >> n >> k; for(int i = 1; i <= n; ++i) cin >> a[i]; for(int i = 1; i <= n; ++i) pre[i] = pre[i - 1] + a[i]; int best = -1e12; for(int i = n; i >= 1; --i) { for(int j = 1; j <= k; ++j) { dp[i][j] = dp[i + 1][j]; best = max(best, dp[i + 1][j - 1] + pre[i]); dp[i][j] = max(dp[i][j], best - pre[i - 1]); } } cout << dp[1][k] << '\n'; }
#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...