# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
35748 | amidethuong2 | Split the sequence (APIO14_sequence) | C++98 | 0 ms | 2372 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;
int cd,k,m[301],kq[301][301],t[301];
void inp()
{
cin >> cd >> k;
t[0] = 0;
for (int i = 1 ; i <= cd ; i++)
{
cin >> m[i];
t[i] = t[i-1] + m[i];
}
}
void cease()
{
int result = -1;
for (int e = 1 ; e <= k ; e++)
{
for (int i = 1 ; i <= cd-1 ; i++)
{
kq[i][e] = -999999999;
if (e == 1)
{
kq[i][e] = t[i] * (t[cd] - t[i]);
}
else
{
int Max = -1;
for (int vl = 1 ; vl < i ; vl++)
{
Max = max(Max,kq[vl][e-1] + (t[i]-t[vl])*(t[cd] - t[i]) );
}
kq[i][e] = Max;
}
if (e == k) result = max(result,kq[i][e]);
}
}
cout << result;
}
main()
{
inp();
cease();
}
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... |