#C10879. Equal Sum Split
Equal Sum Split
Equal Sum Split
You are given a list of non-negative integers. Your task is to determine whether the list can be partitioned into two non-empty sublists such that the sum of the elements in both sublists are equal.
Let \( S = \sum_{i=1}^{n} a_i \) be the total sum of the list. In order to split the list into two parts with equal sums, \( S \) must be even. Define the target sum as \( T = S/2 \). The problem reduces to determining if there exists a nonempty subset (which is not the whole list) whose sum is exactly \( T \).
If such a subset exists, output True
, otherwise output False
.
inputFormat
The first line contains an integer n indicating the number of elements in the list.
The second line contains n space-separated non-negative integers.
Input is read from standard input (stdin).
outputFormat
Output a single line: True
if the list can be split into two non-empty parts with equal sums, or False
otherwise. The output should be written to standard output (stdout).
4
1 5 11 5
True