#K91172. Minimum Size Subarray Sum

    ID: 37917 Type: Default 1000ms 256MiB

Minimum Size Subarray Sum

Minimum Size Subarray Sum

Given an array of non-negative integers and a target integer \(T\), your task is to find the minimum length of a contiguous subarray of which the sum is at least \(T\). If no such subarray exists, output 0.

This problem can be solved efficiently using the sliding window technique.

inputFormat

The input consists of two lines:

  • The first line contains two integers \(n\) and \(T\), where \(n\) is the number of elements in the array and \(T\) is the target sum.
  • The second line contains \(n\) space-separated integers representing the elements of the array.

outputFormat

Output a single integer representing the minimum length of a contiguous subarray whose sum is at least \(T\). If no such subarray exists, output 0.

## sample
6 7
2 3 1 2 4 3
2