QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#183128 | #5475. Make a Loop | real_sigma_team | WA | 2ms | 11852kb | C++20 | 1.2kb | 2023-09-19 03:51:55 | 2023-09-19 03:51:55 |
Judging History
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'