fork download
  1. t = int(input())
  2. for o in range(t):
  3. l = int(input())
  4. n = int(input())
  5. bars = [int(x) for x in input().split()]
  6. bl = 0
  7. cl = [bars[0]]
  8. for i in range(1, n):
  9. r = len(cl)
  10. for x in range(r):
  11. if bars[i] + cl[x] == l or l == 0:
  12. bl = 1
  13. break
  14. cl.append(bars[i] + cl[x])
  15. if bl == 1:
  16. print('YES')
  17. else:
  18. print('NO')
Success #stdin #stdout 0.03s 9784KB
stdin
4
25
4
10 12 5 7
925
10
45 15 120 500 235 58 6 12 175 70
120
5
25 25 25 25 25
0
2
13 567
stdout
NO
YES
NO
YES