#C8358. Equal Sum Partition

    ID: 52331 Type: Default 1000ms 256MiB

Equal Sum Partition

Equal Sum Partition

You are given a list of non-negative integers. Your task is to determine whether the list can be partitioned into two subsets such that the sum of the elements in both subsets is equal.

Let the list be denoted by \(a_1, a_2, \dots, a_n\). You need to decide if there exists a partition of the list into two disjoint subsets \(S_1\) and \(S_2\) such that

\(\sum_{a_i \in S_1} a_i = \sum_{a_i \in S_2} a_i\)

If the list is empty, consider it as being partitionable (i.e. return True).

inputFormat

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

  • The first line contains a single integer \(n\) \( (0 \leq n \leq 10^5)\) representing the number of elements in the list.
  • The second line contains \(n\) non-negative integers separated by spaces.

outputFormat

Output a single line to standard output (stdout) containing either True or False (without quotes) depending on whether the list can be partitioned into two subsets with equal sum.

## sample
4
1 5 11 5
True