This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// #cheat_when_we_are_young
// #cheatkhitacontre #khionhatoicheat
// #thaycuckythatvong
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
using namespace std;
const int NM = 2005;
int n, k, a[NM], dp[NM][NM];
signed main() {
IOS;
cin >> n >> k;
for (int i = 1; i <= n; ++i) {
cin >> a[i];
a[i] += a[i-1];
}
for (int i = 1; i <= n; ++i) for (int j = 1; j <= k; ++j) {
dp[i][j] = max(dp[i][j], dp[i-1][j]);
for (int p = 0; p < i; ++p) dp[i][j] = max(dp[i][j], dp[p][j-1] + a[i] - a[p]);
}
cout << dp[n][k];
}
# | 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... |