#K61702. Equal Sum Partition of Packages

    ID: 31368 Type: Default 1000ms 256MiB

Equal Sum Partition of Packages

Equal Sum Partition of Packages

Given a list of package weights, determine whether it is possible to partition the packages into two groups so that the sum of the weights in both groups is equal. Formally, given an integer array \(A\), the problem is to decide if there exists a subset \(S\) such that \[ \sum_{x \in S} x = \frac{\sum_{x \in A} x}{2} \] provided that the total sum is even. If the total sum is odd, an equal partition is impossible. This classic problem can be solved using dynamic programming by checking whether a subset with a target sum (half of the total sum) exists.

inputFormat

The first line contains a single integer (n), the number of packages. The second line contains (n) space-separated integers representing the weights of the packages.

outputFormat

Output a single line: "True" if the packages can be partitioned into two groups with equal sum; otherwise, output "False".## sample

4
1 5 11 5
True

</p>