# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
64759 | leejseo | Split the sequence (APIO14_sequence) | C++11 | 514 ms | 5776 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 endl '\n'
typedef long long lld;
const static int MAXN = 1005;
const static int MAXK = 205;
int N, K, P[MAXN][MAXK];
lld S[MAXN], D[MAXN][MAXK];
void input(){
cin >> N >> K;
for (int i=1; i<=N; i++){
cin >> S[i];
S[i] += S[i-1];
}
}
int DP(){
memset(D, -1, sizeof(D));
for (int i=1; i<=N; i++) D[i][0] = 0;
for (int i=1; i<=N; i++){
for (int j=1; j<=min(K, i-1); j++){
int prev = -1;
for (int k=1; k<i; k++){
if (D[k][j-1] == -1) continue;
lld val = D[k][j-1] + S[k] * (S[i] - S[k]);
if (val > D[i][j]){
prev = k;
D[i][j] = val;
# | 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... |