제출 #1135537

#제출 시각아이디문제언어결과실행 시간메모리
1135537TAFHBootfall (IZhO17_bootfall)C++20
0 / 100
0 ms320 KiB
#include <bits/stdc++.h>

#define forn(i, n) for (int i = 0; i < n; i++)
#define ull unsigned long long
#define ll long long
#define int long long
#define SPEED                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0)

using namespace std;
const int N = 4e5 + 13;
const int maxa = 2e5 + 13;
const ll mod = 1e8 + 7;
using tp = tuple<ll, ll, ll>;
const int mxn = 2e5 + 13;
const int mxa = 500 + 13;

void prestart() {}

void start() {
    int n;
    cin >> n;

    int a[n];
    forn(i, n) cin >> a[i];

    bool dp[n + 1][mxa];
    for(int i = 0; i <= n; i++) {
        fill(dp[i], dp[i] + mxa, false);
        dp[i][0] = true;
    }

    for(int j = 0; j <= n; j++) {
        for(int i = 0; i < n; i++) {
            if (i == j) continue;
            for(int w = mxa - 1; w >= a[i]; w--) {
                dp[j][w] |= dp[j][w - a[i]];
            }
        }
    }

    int sm = accumulate(a, a + n, 0LL);
    vector<int> ans;
    for(int i = 1; i < mxa; i++) {
        bool flag = true;
        for(int j = 0; j <= n; j++) {
            int tmp = sm - a[j] + i;
            if (!(tmp % 2 == 0 && dp[j][tmp / 2])) {
                flag = false;
                break;
            }
        }

        if (flag) {
            ans.push_back(i);
        }
    }

    cout << (int)ans.size() << "\n";
    for(int i : ans) {
        cout << i << " ";
    }
    cout << "\n";
    return;
}


signed main()
{
    SPEED;
    int t = 1;
    prestart();
    // cin >> t;
    while (t--)
    {
        start();
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...