This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#define fast ios::sync_with_stdio(false); cin.tie(0)
#define foru(i, k, n) for (int i = k; i < n; i++)
#define ford(i, k, n) for (int i = k; i >= n; i--)
#define pb push_back
#define mp make_pair
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <list>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int sz = 3e3;
int n, k;
ll a[sz], dpy[sz][sz], dpn[sz][sz];
int main() {
fast;
cin >> n >> k;
foru(i, 0, n)cin >> a[i];
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= k; j++) {
dpy[i][j] = a[i - 1] + max(dpn[i - 1][j - 1], dpy[i - 1][j]);
dpn[i][j] = max(dpn[i - 1][j], dpy[i - 1][j]);
}
}
cout << max(dpy[n][k], dpn[n][k]) << '\n';
return 0;
}
# | 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... |