Submission #724981

# Submission time Handle Problem Language Result Execution time Memory
724981 2023-04-16T12:08:27 Z AndrijaM Split the sequence (APIO14_sequence) C++14
0 / 100
2000 ms 980 KB
#include <bits/stdc++.h>

using namespace std;

const int maxn=1e5+10;
int n;
int k;
int x[maxn];
int sum[maxn];
vector<int>ans;

int f(int idx,int kol,vector<int>v)
{
    if(kol==0)
    {
        ans=v;
        return sum[n-1]-sum[idx];
    }
    int rez=0;
    for(int i=idx+1;i<n-1;i++)
    {
        vector<int>pom;
        pom=v;
        pom.push_back(i);
        if(idx==-1)
        {
            int koj=kol-1;
            if(koj>=0)
            rez=max(rez, f(i,koj,pom)*sum[i]);
        }
        else
        {
            int koj=kol-1;
            if(koj>=0)
            rez=max(rez, f(i,koj,pom)*(sum[i]-sum[idx]));
        }
    }
    return rez;
}

int main()
{
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        cin>>x[i];
        if(i==0)
        {
            sum[i]=x[i];
        }
        else
        {
            sum[i]=sum[i-1]+x[i];
        }
    }

    vector<int>v;
    cout<<f(-1,k,v)<<endl;
    for(auto p:ans)
    {
        cout<<p<<" ";
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB declared answer doesn't correspond to the split scheme: declared = 320, real = 92
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 212 KB declared answer doesn't correspond to the split scheme: declared = 478040000, real = 1061023
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 98 ms 212 KB declared answer doesn't correspond to the split scheme: declared = 2135969248, real = 514120000
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2071 ms 212 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2037 ms 340 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2065 ms 980 KB Time limit exceeded
2 Halted 0 ms 0 KB -