QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#183128#5475. Make a Loopreal_sigma_teamWA 2ms11852kbC++201.2kb2023-09-19 03:51:552023-09-19 03:51:55

Judging History

你现在查看的是最新测评结果

  • [2023-09-19 03:51:55]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:11852kb
  • [2023-09-19 03:51:55]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

using ll = long long;

const int N = 101;
const int R = 1e4 + 1;

int dp[N][N * R], r[N];

void solve() {
    dp[0][0] = 1;

    int n;
    cin >> n;

    if (n & 1) {
        cout << "No\n";
        return;
    }

    int sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> r[i];
        sum += r[i];
    }

    if (sum & 1) {
        cout << "No\n";
        return;
    }

    int need = sum / 2;

    sum = 0;

    for (int i = 0; i < n; i++) {
        int ri = r[i];
        int br = min(sum, need - ri);
        for (int j = i; j >= 0; j--) {
            for (int l = 0; l <= br; l++) {
                dp[j + 1][l + ri] += dp[j][l];
                dp[j + 1][l + ri] = min(dp[j + 1][l + ri], 4);
            }
        }
        sum += ri;
    }
    int cnt = dp[n / 2][need] / 2;
    for (int i = 2; i < n / 2; i += 2) {
        cnt += dp[i][need];
    }

    cout << (cnt >= 2 ? "Yes" : "No") << '\n';
}

int main() {
#ifndef LOCAL
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#else
    freopen("input.txt", "r", stdin);
#endif
    solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 11852kb

input:

4
1 1 1 1

output:

Yes

result:

ok single line: 'Yes'

Test #2:

score: 0
Accepted
time: 0ms
memory: 7828kb

input:

6
1 3 1 3 1 3

output:

Yes

result:

ok single line: 'Yes'

Test #3:

score: -100
Wrong Answer
time: 1ms
memory: 7764kb

input:

6
2 2 1 1 1 1

output:

Yes

result:

wrong answer 1st lines differ - expected: 'No', found: 'Yes'