#C9950. Longest Contiguous Subsequence Sum

    ID: 54100 Type: Default 1000ms 256MiB

Longest Contiguous Subsequence Sum

Longest Contiguous Subsequence Sum

Given an integer sequence of length \(N\) and a target sum \(S\), your task is to find the length of the longest contiguous subsequence whose sum equals \(S\). If no such subsequence exists, output 0.

For example, consider the sequence [1, 2, 3, 7, 5] with \(S = 12\). The longest contiguous subsequence that sums to 12 is of length 3 (e.g. [2, 3, 7]).

inputFormat

The input consists of two lines. The first line contains two integers (N) and (S). The second line contains (N) space-separated integers representing the sequence.

outputFormat

Output a single integer representing the length of the longest contiguous subsequence whose sum equals (S). If there is no such subsequence, output 0.## sample

5 12
1 2 3 7 5
3