#K44407. Equal Subset Sum Partition

    ID: 27524 Type: Default 1000ms 256MiB

Equal Subset Sum Partition

Equal Subset Sum Partition

Given a list of integers, determine whether it is possible to partition the list into two subsets such that the sum of the elements in both subsets are equal.

Let \(S = \sum_{i=1}^{n} a_i\) be the total sum of the list. A necessary condition for the partition to be possible is that \(S \mod 2 = 0\). The problem then reduces to finding a subset of the list with sum \(S/2\). Dynamic programming is a common technique used to solve this problem efficiently.

inputFormat

The input is given via standard input (stdin) with the following format:

  1. The first line contains an integer \(n\) denoting the number of elements in the list.
  2. The second line contains \(n\) space-separated integers representing the elements of the list.

outputFormat

Output a single line to standard output (stdout) with the string True if the list can be partitioned into two subsets with equal sum, or False otherwise.

## sample
4
1 5 11 5
True