Submission #93358

# Submission time Handle Problem Language Result Execution time Memory
93358 2019-01-07T17:50:46 Z toloraia Bootfall (IZhO17_bootfall) C++14
0 / 100
2 ms 376 KB
#include <bits/stdc++.h>
#define ll long long int
using namespace std;

const int N = 505, M = 260010;
const int B = 1e9 + 7;

int n;
int a[N];
int S;
int DP[M];
int dp[M];
int ans[M], ANS[M];
int V[M], np;
int main()
{
    cin>>n;
    for (int i = 1; i <= n; i++){
        cin>>a[i];
        S += a[i];
    }
    sort (a + 1, a + n + 1);
    bool ok = 0;
    for (int i = 2; i <= n; i++)
        if ((a[i] - a[i - 1]) % 2 == 1)
            ok = 1;
    if (S % 2 == 1)
        ok = 1;
    if (ok){
        cout<<0<<endl;
        return 0;
    }
    DP[0] = 1;
    for (int i = 1; i <= n; i++){
        for (int j = S; j >= a[i]; j--){
            DP[j] += DP[j - a[i]];
            if (DP[j] >= B)
                DP[j] -= B;
        }
    }
    if (DP[S / 2] == 0){
        cout<<0<<endl;
        return 0;
    }
    for (int I = 1; I <= n; ++I){
        for (int i = 0; i <= S; ++i){
            dp[i] = DP[i];
            ans[abs (S - 2 * i - a[I])] = 0;
        }
        for (int i = 0; i <= S; ++i){
            if (i >= a[I]){
                dp[i] -= dp[i - a[I]];
                if (dp[i] < 0)
                    dp[i] += B;
            }
            int x = abs (S - a[i] - 2 * i);
            if (dp[i] > 0 && ans[x] == 0){
                ans[x] = 1;
                ANS[x]++;
            }
        }
    }
    np = 0;
    for (int i = 0; i <= S; i++)
        if (ANS[i] == n)
            V[np++] = i;
    cout<<np<<endl;
    for (int i = 0; i < np; i++)
        cout<<V[i]<<" ";
    cout<<endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -