#C1744. Target Expression Achievability
Target Expression Achievability
Target Expression Achievability
You are given a sequence of n integers and a target integer T. Your task is to determine whether it is possible to insert '+' or '-' operators before each element of the sequence (starting from an initial sum of 0) such that the resulting expression evaluates exactly to T. Formally, if the sequence is \(a_1, a_2, \dots, a_n\), determine if there exists a choice of signs such that:
\(0 \pm a_1 \pm a_2 \pm \cdots \pm a_n = T\)
The answer should be YES
if it is possible, and NO
otherwise.
inputFormat
The first line of input contains two integers n and T separated by a space. The second line contains n integers separated by spaces representing the sequence.
outputFormat
Output a single line containing YES
if it is possible to achieve the target T by inserting '+' or '-' operators before each element, or NO
if it is not.## sample
5 3
1 2 3 4 5
YES