-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10664.cpp
More file actions
54 lines (51 loc) · 1.12 KB
/
10664.cpp
File metadata and controls
54 lines (51 loc) · 1.12 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
54
#include <bits/stdc++.h>
using namespace std;
int w[25];
int main()
{
//freopen("in.txt", "rt", stdin);
//freopen("out.txt", "w+t", stdout);
int t;
scanf("%d\n",&t);
char buffer[1024];
while(t--)
{
fgets(buffer,1024,stdin);
int len(0),total(0);
char *p = strtok(buffer," ");
w[len++] = atoi(p);
total = w[0];
while(1)
{
p = strtok(NULL," ");
if(p==NULL)
break;
w[len] = atoi(p);
total+=w[len++];
}
if(total&1)
{
printf("NO\n");
continue;
}
bool f[total+1];
memset(f,0,sizeof(bool)*(total+1));
f[0] = 1;
total/=2;
for(int i=0;i<len;i++)
{
for(int j=total;j>=w[i];j--)
{
if(f[j-w[i]])
f[j] = 1;
}
if(f[total])
break;
}
if(f[total])
printf("YES\n");
else
printf("NO\n");
}
return 0;
}