Submission #333274

# Submission time Handle Problem Language Result Execution time Memory
333274 2020-12-05T07:00:46 Z blue Split the sequence (APIO14_sequence) C++11
0 / 100
2000 ms 5396 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] == 0) ? 1 : 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 0 ms 364 KB contestant found the optimal answer: 999 == 999
3 Correct 1 ms 364 KB contestant found the optimal answer: 0 == 0
4 Correct 1 ms 364 KB contestant found the optimal answer: 1542524 == 1542524
5 Incorrect 1 ms 364 KB position 1 occurs twice in split scheme
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 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 position 1 occurs twice in split scheme
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 position 1 occurs twice in split scheme
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 6 ms 364 KB contestant found the optimal answer: 140412195 == 140412195
3 Incorrect 158 ms 1900 KB position 1 occurs twice in split scheme
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 389 ms 620 KB contestant found the optimal answer: 1818678304 == 1818678304
2 Correct 199 ms 620 KB contestant found the optimal answer: 1326260195 == 1326260195
3 Execution timed out 2087 ms 5396 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2083 ms 1516 KB Time limit exceeded
2 Halted 0 ms 0 KB -