#C4447. Minimum Subarray Length
Minimum Subarray Length
Minimum Subarray Length
You are given an array of integers and a target integer S. Your task is to find the length of the smallest contiguous subarray such that the sum of its elements is greater than or equal to S.
Formally, given an array \(a\) of \(n\) integers and an integer \(S\), find the minimum length \(L\) such that there exist indices \(l\) and \(r\) with \(1 \leq l \leq r \leq n\) satisfying:
\(\sum_{i=l}^{r} a_i \geq S\)
If no such subarray exists, output 0.
inputFormat
The input is read from standard input (stdin) and has the following format:
- The first line contains two integers \(n\) and \(S\) separated by a space, where \(n\) is the number of elements in the array.
- The second line contains \(n\) space-separated integers representing the array \(a\).
outputFormat
Print a single integer to standard output (stdout) representing the length of the smallest contiguous subarray whose sum is greater than or equal to \(S\). If no such subarray exists, print 0.
## sample6 7
2 3 1 2 4 3
2