TopCoder

User's AC Ratio

98.3% (177/180)

Submission's AC Ratio

54.5% (327/600)

Tags

Description

假設有 N個正整數A[1], A[2],..., A[N],我們要在每一個數字之前加入+號或-號使得它們的總和為0。例如: 1, 2 及 3,我們可以得到
(-1)+(-2)+(+3)=0;但是對於2, 2 及 1 則無法透過加入+號或-號使得它們的總和為 0。

請你寫一個程式來判斷任意N個正整數是否可以透過加入+號或-號使得它們的總和為 0。

Input Format

輸入檔的第一行有兩個正整數, M及N以空白區分,代表有M組測試資料,每一組有 N個正整數。

第二行至第 M+1 行則則分別輸入所訂定的 N個正整數,以空白區分。其中 0<M≤10,且0<N≤100。每個正整數都不會超過1000。

Output Format

對於每一組測試資料,若可以找到加入+號或-號使得它們的總和為 0 時,請輸出 Yes;否則請輸出 No。

Sample Input 1

4 3
1 2 3
3 2 1
2 2 2
5 1 6

Sample Output 1

Yes
Yes
No
Yes

Sample Input 2

2 8
1 2 3 4 5 6 7 8
12 12 10 11 34 22 33 26

Sample Output 2

Yes
Yes

Hints

Problem Source

原TIOJ1508 / TOI2008初選(prob 3)

Subtasks

No. Testdata Range Score
1 0 20
2 1 20
3 2 20
4 3 20
5 4 20

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 10000 65536 262144 1
1 10000 65536 262144 2
2 10000 65536 262144 3
3 10000 65536 262144 4
4 10000 65536 262144 5