// UVa 10664 - Luggage
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
int main(void) {
string line;
int t;
cin >> t;
getline(cin, line);
int a[20];
int i;
bool T[201];
for (; t > 0; t--) {
getline(cin, line);
stringstream ss(line);
int n = 0;
while (ss.good()) {
ss >> a[n++];
}
int sum = 0;
for (int i = 0; i < n; i++)
sum += a[i];
if (sum % 2 == 1)
cout << "NO" << endl;
else {
sum = sum / 2;
T[0] = true;
for (int j = 1; j <= sum; j++)
T[j] = false;
for (int i = 0; i < n; i++) {
for (int j = sum; j >= a[i]; j--)
if (T[j - a[i]]) {
T[j] = true;
}
}
if (T[sum])
cout << "YES" << endl;
else
cout << "NO" << endl;
}
}
return 0;
}
Monday, August 31, 2015
UVa 10664 - Luggage
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment