# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
224766 | tictaccat | Feast (NOI19_feast) | C++14 | 1095 ms | 3668 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
int N,K;
int A[500000];
int dp[2][2500];
int best[2][2500];
main() {
cin >> N >> K;
for (int i = 0; i < N; i++) cin >> A[i];
for (int i = 0; i < N; i++) {
for (int k = 1; k <= K; k++) {
dp[i%2][k] = A[i] + max(dp[(i+1)%2][k],best[(i+1)%2][k-1]);
best[i%2][k] = max(best[(i+1)%2][k], dp[i%2][k]);
}
}
cout << best[(N+1)%2][K] << "\n";
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |