-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy path1552D.cpp
More file actions
44 lines (40 loc) · 648 Bytes
/
Copy path1552D.cpp
File metadata and controls
44 lines (40 loc) · 648 Bytes
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
#include <bits/stdc++.h>
using namespace std;
int A[100];
int n;
int val = 0;
int tgt = 0;
bool good = false;
void solve(int x) {
if (val == A[tgt]) good = true;
if (x == n) {
return;
}
solve(x+1);
if (tgt != x) {
val += A[x];
solve(x+1);
val -= A[x];
val -= A[x];
solve(x+1);
val += A[x];
}
}
int main() {
int t; cin >> t;
while (t--) {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> A[i];
}
good = false;
for (int i = 0; i < n; i++) {
val = 0;
tgt = i;
solve(0);
}
if (good) cout << "YES" << endl;
else cout << "NO" << endl;
}
return 0;
}