Submission #333273

# Submission time Handle Problem Language Result Execution time Memory
333273 2020-12-05T06:58:50 Z blue Split the sequence (APIO14_sequence) C++11
0 / 100
2000 ms 5756 KB
#include <iostream>
using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;

    int a[n+1];
    a[0] = 0;
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i];
        a[i] += a[i-1];
    }

    int dp[n+1][k+1];
    int prev[n+1][k+1];
    for(int i = 1; i <= n; i++)
    {
        dp[i][0] = 0;
        prev[i][0] = 0;
        for(int l = 1; l < n && l <= k; l++)
        {
            dp[i][l] = 0;
            prev[i][l] = 0;

            for(int j = l; j < i; j++)
            {
                if(dp[j][l-1] + a[j] * (a[i] - a[j]) > dp[i][l])
                {
                    dp[i][l] = dp[j][l-1] + a[j] * (a[i] - a[j]);
                    prev[i][l] = j;
                }
            }
        }
    }
    cout << dp[n][k] << '\n';

    int temp = n;
    for(int l = k; l >= 1; l--)
    {
        cout << prev[temp][l] << ' ';
        temp = prev[temp][l];
    }
    cout << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB contestant found the optimal answer: 108 == 108
2 Correct 1 ms 364 KB contestant found the optimal answer: 999 == 999
3 Incorrect 1 ms 364 KB Integer 0 violates the range [1, 1]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB contestant found the optimal answer: 1093956 == 1093956
2 Correct 1 ms 364 KB contestant found the optimal answer: 302460000 == 302460000
3 Incorrect 1 ms 364 KB Integer 0 violates the range [1, 49]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB contestant found the optimal answer: 610590000 == 610590000
2 Correct 1 ms 364 KB contestant found the optimal answer: 311760000 == 311760000
3 Incorrect 4 ms 620 KB Integer 0 violates the range [1, 199]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 364 KB contestant found the optimal answer: 21503404 == 21503404
2 Correct 3 ms 364 KB contestant found the optimal answer: 140412195 == 140412195
3 Incorrect 161 ms 1900 KB Integer 0 violates the range [1, 999]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 387 ms 748 KB contestant found the optimal answer: 1818678304 == 1818678304
2 Correct 198 ms 748 KB contestant found the optimal answer: 1326260195 == 1326260195
3 Execution timed out 2083 ms 5756 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2061 ms 1484 KB Time limit exceeded
2 Halted 0 ms 0 KB -