#C4130. Subsequence Sum Finder
Subsequence Sum Finder
Subsequence Sum Finder
You are given a list of positive integers representing gem rarities, and a target sum \( T \). Your task is to determine whether there exists any continuous subsequence in the list whose sum is exactly equal to \( T \). This problem can be efficiently solved using the sliding window (two-pointer) technique.
For example, if the list is [1, 2, 3, 7, 5] and the target is 12, one valid subsequence is [2, 3, 7] which sums to 12, so the answer is True
.
inputFormat
The input is read from standard input (stdin) and consists of two lines:
- The first line contains a single integer \( T \), the target sum.
- The second line contains a space-separated list of positive integers representing gem rarities.
outputFormat
Output a single line to standard output (stdout) containing True
if a continuous subsequence exists whose sum equals the target \( T \), or False
if no such subsequence exists.
12
1 2 3 7 5
True