# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
196907 | quocnguyen1012 | Split the sequence (APIO14_sequence) | C++14 | 2013 ms | 44792 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>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 5;
ll f[maxn][205];
int N, a[maxn], K;
ll sum[maxn];
signed main(void)
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
if (fopen("A.INP", "r")){
freopen("A.INP", "r", stdin);
freopen("A.OUT", "w", stdout);
}
cin >> N >> K;
for (int i = 1; i <= N; ++i){
cin >> a[i];
sum[i] = sum[i - 1] + a[i];
}
for (int j = 1; j <= K; ++j){
for (int i = 1; i <= N; ++i){
for (int k = 0; k < i; ++k){
f[i][j] = max(f[i][j], f[k][j - 1] + 1ll * (sum[i] - sum[k]) * sum[k]);
}
}
}
cout << f[N][K];
}
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... |