-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10664-2.cpp
More file actions
53 lines (51 loc) · 1.14 KB
/
Copy path10664-2.cpp
File metadata and controls
53 lines (51 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <bits/stdc++.h>
using namespace std;
int a[25], N, n;
int dp[25][200];
bool dc[25][200];
int call(int k, int rem) {
if (k == n) {
if (rem == N)
return 1;
else
return 0;
}
if (rem == N) return 1;
if (dc[k][rem]) return dp[k][rem];
int x = 0, y = 0;
if (a[k] + rem <= N) x = call(k + 1, a[k] + rem);
y = call(k + 1, rem);
dc[k][rem] = 1;
return dp[k][rem] = max(x, y);
}
int main() {
char ch;
int i, j, k, S, sum, t;
scanf("%d", &t);
getchar();
while (t--) {
n = 0, sum = 0, k = 0;
while (ch = getchar()) {
if (ch >= '0' && ch <= '9') {
k = k * 10 + ch - '0';
} else if (ch == ' ' || ch == '\n') {
a[n] = k;
sum += k;
k = 0;
n++;
}
if (ch == '\n') break;
}
if (sum % 2 == 1) {
puts("NO");
continue;
}
memset(dc, 0, sizeof(dc));
N = sum / 2;
if (call(0, 0)) {
puts("YES");
} else
puts("NO");
}
return 0;
}