3147 - Sum Challenge 3147 - Sum Challenge 3147 - Sum Challenge

Statistics Sub: 776 | AC: 273 | AC%: 35,18 | Score: 0,71
Created by Yonny Mondelo Hernández
Added by ymondelo20 (2015-03-06)
Limits
Total Time: 15000 MS | Test Time: 1500 MS |Memory: 125 MB | Output: 64 MB | Size: 14 KB
Enabled languages
Available in

Description

Given a set of signed integers, find if there is a non-empty consecutive subset whose sum is zero.

Examples:
L = [-4, -7, 10, 6, 4] -: NO
L = [-5, -2, -3, 5, 8] -: YES (because [-2, -3, 5] sums to zero).
Given a set of signed integers, find if there is a non-empty consecutive subset whose sum is zero.

Examples:
L = [-4, -7, 10, 6, 4] -: NO
L = [-5, -2, -3, 5, 8] -: YES (because [-2, -3, 5] sums to zero).
Given a set of signed integers, find if there is a non-empty consecutive subset whose sum is zero.

Examples:
L = [-4, -7, 10, 6, 4] -: NO
L = [-5, -2, -3, 5, 8] -: YES (because [-2, -3, 5] sums to zero).

Input specification

The first line contain a integer number 1 <= T <= 100 representing the number of test cases. For each test case will be a line with a integer number 1 <= N <= 50, followed by N integers between -100 and 100 (all numbers in the line are space-separated).
The first line contain a integer number 1 <= T <= 100 representing the number of test cases. For each test case will be a line with a integer number 1 <= N <= 50, followed by N integers between -100 and 100 (all numbers in the line are space-separated).
The first line contain a integer number 1 <= T <= 100 representing the number of test cases. For each test case will be a line with a integer number 1 <= N <= 50, followed by N integers between -100 and 100 (all numbers in the line are space-separated).

Output specification

For each test case you must print a line with the word YES if a non-empty consecutive subset with sum zero exists, or NO otherwise.
For each test case you must print a line with the word YES if a non-empty consecutive subset with sum zero exists, or NO otherwise.
The first line contain a integer number 1 <= T <= 100 representing the number of test cases. For each test case will be a line with a integer number 1 <= N <= 50, followed by N integers between -100 and 100 (all numbers in the line are space-separated).

Sample input

2
5 -4 -7 10 6 4
5 -5 -2 -3 5 8

Sample output

NO
YES

Hint(s)

http://coj.uci.cu/24h/
http://coj.uci.cu/24h/
http://coj.uci.cu/24h/

Recommendation

We have carefully selected several similar problems: 1000 | 3378 | 1049 | 1494 | 1028 | 3573