Submission #650701

# Submission time Handle Problem Language Result Execution time Memory
650701 2022-10-14T18:13:13 Z sofija6 Kpart (eJOI21_kpart) C++14
0 / 100
83 ms 14264 KB
#include <bits/stdc++.h>
#define ll int
#define MAXN 1010
#define MAXS 100010
using namespace std;
ll a[MAXN],dp[MAXN][MAXS/2],pref[MAXN];
bool yes[MAXN];
int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll t,n;
    cin >> t;
    while (t--)
    {
        cin >> n;
        for (ll i=1;i<=n;i++)
        {
            cin >> a[i];
            pref[i]=pref[i-1]+a[i];
        }
        for (ll i=1;i<=n;i++)
        {
            yes[i]=true;
            for (ll j=0;j<=pref[n]/2;j++)
                dp[i][j]=0;
        }
        dp[0][0]=0;
        for (ll i=1;i<=n;i++)
        {
            for (ll j=a[i];j<=pref[n]/2;j++)
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-a[i]]);
            dp[i][a[i]]=i;
        }
        ll ans=n;
        for (ll i=1;i<=n;i++)
        {
            for (ll j=i;j<=n;j++)
            {
                if (!yes[j-i+1])
                    continue;
                if ((pref[j]-pref[i-1])&1 || dp[j][(pref[j]-pref[i-1])/2]<i)
                {
                    yes[j-i+1]=false;
                    ans--;
                }
            }
        }
        cout << ans << " ";
        for (ll i=1;i<=n;i++)
        {
            if (yes[i])
                cout << i << " ";
        }
        cout << "\n";
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 596 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 1620 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 83 ms 14264 KB Output isn't correct
2 Halted 0 ms 0 KB -