#C10143. Subset Sum Zero
Subset Sum Zero
Subset Sum Zero
Given a list of integers, determine whether there exists a non-empty subset whose sum is zero. Formally, let \( S \) be any non-empty subset of the input integers. You need to check if \( \sum_{x \in S} x = 0 \). If such a subset exists, output YES
; otherwise, output NO
.
inputFormat
The input consists of two lines:
- The first line contains an integer \( n \) denoting the number of integers.
- The second line contains \( n \) space-separated integers.
outputFormat
Output a single line with YES
if there exists a non-empty subset of the given integers that sums to zero; otherwise, output NO
.
5
-1 2 -3 4 5
YES
</p>