#C5493. Exact Subset Sum
Exact Subset Sum
Exact Subset Sum
Given an integer array \(A\) of size \(n\) and three integers \(n\), \(m\), and \(s\), the task is to determine whether there exists a subset of exactly \(m\) elements from \(A\) such that the sum of its elements equals \(s\). Formally, find if there exists a subset \(S\) of \(A\) with \(|S| = m\) such that \(\sum_{a \in S} a = s\).
The input is read from standard input and the output should be printed to standard output as either True
or False
(without quotes).
inputFormat
The first line contains three space-separated integers: (n) (the number of elements), (m) (the number of elements to choose), and (s) (the target sum).\nThe second line contains (n) space-separated integers representing the elements of the array.
outputFormat
Print True
if there exists a subset of exactly (m) elements with sum equal to (s); otherwise, print False
.## sample
5 2 10
2 4 6 8 10
True