#K41507. Taco: Continuous Subsequence Sum
Taco: Continuous Subsequence Sum
Taco: Continuous Subsequence Sum
You are given an integer N representing the number of paintings and an integer K representing the target sum. You are also provided with a sequence of N integers beauties, where each integer denotes the beauty of a painting. Your task is to determine whether there exists a contiguous subarray (i.e. continuous sequence) of these paintings whose sum equals K.
In other words, you need to check if there exists indices l and r such that:
$$ \sum_{i=l}^{r} beauties_i = K $$
If such a subarray exists, output "Yes"; otherwise, output "No".
inputFormat
The input is given in two lines:
- The first line contains two space-separated integers N and K.
- The second line contains N space-separated integers representing the array beauties.
outputFormat
Output a single line containing either "Yes" if there exists a contiguous subarray whose sum is K, or "No" otherwise.
## sample5 12
2 4 6 3 9
Yes
</p>