Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- const int MAXN = 101;
- const int MAXV = 1001;
- int a[MAXN];
- bitset <MAXN * MAXV> dp;
- void solve() {
- int n;
- cin >> n;
- for (int i = 0; i < n; ++i) cin >> a[i];
- dp &= 0;
- dp[0] = 1;
- for (int i = 0; i < n; ++i) {
- dp |= (dp << a[i]);
- }
- int sum = 0;
- for (int i = 0; i < n; ++i) sum += a[i];
- if (sum % 2 == 0 && dp[sum / 2]) {
- cout << "YES\n";
- }
- else {
- cout << "NO\n";
- }
- }
- signed main() {
- ios_base::sync_with_stdio(0);
- cin.tie(0);
- int t;
- cin >> t;
- for (int i = 0; i < t; ++i) {
- solve();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement