# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
977093 | Amaarsaa | Split the sequence (APIO14_sequence) | C++14 | 2053 ms | 32092 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;
using ll = long long ;
int main() {
// freopen("moocast.in", "r", stdin);
// freopen("moocast.out", "w", stdout);
ios::sync_with_stdio(false);
cin.tie(NULL);
ll t, n, m, ans, s, mx, mx_cnt, x, y, r, p, i, j;
cin >> n >> m;
ll a[n + 2], dp[m + 2][n + 2], sum[n + 2];
sum[0] = 0;
for (i = 1; i <= n; i ++) {
cin >> a[i];
sum[i] = sum[i - 1] + a[i];
}
dp[0][0] = 0;
ll Comes[m +2][n + 2];
for (i = 1; i <= n; i ++) dp[1][i] = sum[i] * (sum[n] - sum[i]), Comes[1][i] = 0;
for (i = 2; i <= m + 1; i ++) {
for (j = 1; j <= n; j ++) {
Comes[i][j] = 0;
dp[i][j] = 0;
for ( r = 1; r < j; r ++) {
if ( dp[i][j] <= dp[i - 1][r] + (sum[j] - sum[r]) * (sum[n] - sum[j])) {
Comes[i][j] = r;
dp[i][j] = dp[i - 1][r] + (sum[j] - sum[r]) * (sum[n] - sum[j]);
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... |