Submission #949378

# Submission time Handle Problem Language Result Execution time Memory
949378 2024-03-19T07:28:56 Z tnknguyen_ Split the sequence (APIO14_sequence) C++14
0 / 100
547 ms 16444 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n' 

const int sz = 1e4 + 5;
long long a[sz], s[sz];
int n, k;

namespace SUB123{
    bool ok(){
        return (n <= 200);
    }

    void solve(){
        vector<vector<int>> f(n+5, vector<int>(k+5, 0));
        for(int j=1; j<=k+1; ++j){
            for(int i=1; i<=n; ++i){
                int L = 0, R = s[n] - s[i];
                for(int g=i; g>=j; --g){
                    L += a[g];
                    f[i][j] = max(f[i][j], f[g-1][j-1] + (L * R));
                }
            }
        }

        cout<<f[n][k+1];
        //---------------------
        exit(0);
    }
}

int f[sz][205];
int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    //freopen("main.inp","r",stdin);
    //freopen("main.out","w",stdout);

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

    // SUB123::solve();
    for(int j=1; j<=k+1; ++j){
            for(int i=1; i<=n; ++i){
                int L = 0, R = s[n] - s[i];
                for(int g=i; g>=j; --g){
                    L += a[g];
                    f[i][j] = max(f[i][j], f[g-1][j-1] + (L * R));
                }
            }
        }

        cout<<f[n][k+1];

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 604 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 604 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 1884 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 547 ms 16444 KB Unexpected end of file - int32 expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 860 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -