#K71012. Equal Sum Partition

    ID: 33437 Type: Default 1000ms 256MiB

Equal Sum Partition

Equal Sum Partition

You are given an array A of integers with even length n. Your task is to determine whether it is possible to partition A into two subarrays such that the sum of the elements in each subarray is equal.

If such a partition exists, output YES on the first line and on the second line output the 1-based indices (in increasing order) of one of the subarrays which sums to half of the total sum. Otherwise, output NO.

This is equivalent to finding a subset of A whose sum is exactly \(\frac{1}{2}\) of the total sum. A dynamic programming approach can be used to solve this problem efficiently.

inputFormat

The input consists of two lines:

  1. The first line contains an even integer n, the number of elements in the array.
  2. The second line contains n space-separated integers, representing the elements of the array A.

outputFormat

If a valid partition exists, output YES followed by a newline and then the 1-based indices of one subarray forming the equal partition in increasing order, separated by spaces.

If no valid partition exists, output NO.

## sample
4
1 2 3 4
YES

1 4

</p>