Submission #960873

# Submission time Handle Problem Language Result Execution time Memory
960873 2024-04-11T07:05:34 Z vjudge1 Split the sequence (APIO14_sequence) C++17
11 / 100
1 ms 600 KB
#include<bits/stdc++.h>
using namespace std;
long long dp[11][11],from[11][11],pre[11];
int main(){
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>pre[i],pre[i]+=pre[i-1];
    memset(dp,-2,sizeof dp);
    for(int i=1;i<=n;i++)
        dp[0][i]=0;
    for(int i=1;i<=k;i++)
        for(int j=1;j<=n;j++)
            for(int c=0;c<j;c++)
                if(dp[i][j]<dp[i-1][c]+(pre[j]-pre[c])*pre[c])
                    dp[i][j]=dp[i-1][c]+(pre[j]-pre[c])*pre[c],from[i][j]=c;
    cout<<dp[k][n]<<'\n';
    stack<int>stk;
    while(k)
        stk.push(n=from[k--][n]);
    while(stk.size())
        cout<<stk.top()<<' ',stk.pop();
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB contestant found the optimal answer: 108 == 108
2 Correct 0 ms 348 KB contestant found the optimal answer: 999 == 999
3 Correct 1 ms 348 KB contestant found the optimal answer: 0 == 0
4 Correct 1 ms 348 KB contestant found the optimal answer: 1542524 == 1542524
5 Correct 1 ms 348 KB contestant found the optimal answer: 4500000000 == 4500000000
6 Correct 0 ms 348 KB contestant found the optimal answer: 1 == 1
7 Correct 0 ms 348 KB contestant found the optimal answer: 1 == 1
8 Correct 0 ms 348 KB contestant found the optimal answer: 1 == 1
9 Correct 0 ms 348 KB contestant found the optimal answer: 100400096 == 100400096
10 Correct 0 ms 344 KB contestant found the optimal answer: 900320000 == 900320000
11 Correct 0 ms 600 KB contestant found the optimal answer: 3698080248 == 3698080248
12 Correct 1 ms 348 KB contestant found the optimal answer: 3200320000 == 3200320000
13 Correct 0 ms 348 KB contestant found the optimal answer: 140072 == 140072
14 Correct 0 ms 348 KB contestant found the optimal answer: 376041456 == 376041456
15 Correct 0 ms 348 KB contestant found the optimal answer: 805 == 805
16 Correct 0 ms 348 KB contestant found the optimal answer: 900189994 == 900189994
17 Correct 0 ms 348 KB contestant found the optimal answer: 999919994 == 999919994
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB declared answer doesn't correspond to the split scheme: declared = 3096, real = 824451
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -