#K80302. Partition Equal Subset Sum

    ID: 35500 Type: Default 1000ms 256MiB

Partition Equal Subset Sum

Partition Equal Subset Sum

You are given a list of n integers. Determine whether it is possible to partition the list into two non-empty subsets such that the sum of the elements in each subset is equal.

Let \( S \) be the sum of all elements in the list. In order for the partition to be possible, \( S \) must be even. In that case, the goal is to find a subset of numbers that sums to \( \frac{S}{2} \). Otherwise, if \( S \) is odd or the list has less than two elements, partitioning is impossible.

This is a classic subset sum problem with a twist. The constraints ensure that you need to use a dynamic programming approach to determine whether such a partition exists.

inputFormat

The input is read from stdin and consists of two lines:

  1. The first line contains a positive integer n, the number of elements in the list.
  2. The second line contains n space-separated integers representing the list.

outputFormat

Output to stdout a single line containing either True if the list can be partitioned into two subsets with equal sum, or False otherwise.

## sample
4
1 5 11 5
True

</p>