Submission #677753

# Submission time Handle Problem Language Result Execution time Memory
677753 2023-01-04T10:00:25 Z Tigryonochekk Bootfall (IZhO17_bootfall) C++17
0 / 100
1 ms 212 KB
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define mp make_pair

const int N = 502;

int n;
int a[N];
bool dp[N][N * N];

int main() {
    cin >> n;
    int sum = 0;
    bool isev = 0, isod = 0;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        sum += a[i];
        if (a[i] % 2 == 0)
            isev = 1;
        else
            isod = 1;
    }
    if ((isev && isod) || (sum % 2 == 1)) {
        cout << 0 << endl;
        return 0;
    }

    dp[0][0] = 1;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < a[i]; j++) {
            dp[i][j] = dp[i - 1][j];
        }
        for (int j = a[i]; j <= sum; j++) {
            dp[i][j] = dp[i - 1][j] || dp[i - 1][j - a[i]];
        }
    }
    if (dp[n][sum / 2] == 0) {
        cout << 0 << endl;
        return 0;
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -