#K61157. Equal Subset Partitioning

    ID: 31247 Type: Default 1000ms 256MiB

Equal Subset Partitioning

Equal Subset Partitioning

Given an array of integers arr, determine whether it is possible to partition the array into two subsets such that the sum of the elements in both subsets is equal.

Let \(S = \sum_{i=1}^{n} a_i\) be the total sum of the array. A valid partition can only exist if \(S\) is even. In that case, the problem reduces to finding a subset of \(arr\) whose sum is \(\frac{S}{2}\). If such a subset exists, print Yes, otherwise print No.

inputFormat

The input is given from stdin in the following format:

  1. The first line contains a single integer \(n\) representing the number of elements in the array.
  2. The second line contains \(n\) space-separated integers, which are the elements of the array.

outputFormat

Output to stdout a single line containing Yes if there exists a partition of the array into two subsets with equal sum, and No otherwise.

## sample
4
1 5 11 5
Yes