#C3929. Maximum Contiguous Shelf Subsequence

    ID: 47410 Type: Default 1000ms 256MiB

Maximum Contiguous Shelf Subsequence

Maximum Contiguous Shelf Subsequence

You are given a series of records, each with a specific thickness, and a maximum allowable total thickness T. Your task is to find the length of the longest contiguous subsequence of these records such that the sum of their thicknesses does not exceed T.

Formally, given an integer N representing the number of records, an integer T representing the maximum total thickness, and a list of integers a_1, a_2, \dots, a_N representing the thicknesses of the records, determine the maximum integer L such that there exists an index i for which:

[ \sum_{j=i}^{i+L-1} a_j \le T ]

If no valid subsequence exists (i.e. if each individual record is thicker than T), output 0.

inputFormat

The input is given in two lines:

  • The first line contains two space-separated integers N and T (1 ≤ N ≤ 105, 1 ≤ T ≤ 109).
  • The second line contains N space-separated integers a1, a2, ..., aN (1 ≤ ai ≤ 104), representing the thicknesses of the records.

You should read the input from stdin.

outputFormat

Output a single integer representing the length of the longest contiguous subsequence whose total thickness does not exceed T. The output should be written to stdout.

## sample
6 10
3 1 2 3 4 1
4