#C3572. Longest Subarray With Sum Under Threshold

    ID: 47014 Type: Default 1000ms 256MiB

Longest Subarray With Sum Under Threshold

Longest Subarray With Sum Under Threshold

Given an array of integers and an integer threshold (T), find the length of the longest contiguous subarray whose sum is less than or equal to (T). This problem requires an efficient solution since the size of the array can be large. You are expected to use a sliding window or two-pointer technique to achieve optimal performance.

inputFormat

The first line of input contains a single integer (n) representing the number of elements in the array. The second line contains (n) space-separated integers representing the array elements. The third line contains an integer (T) representing the threshold.

outputFormat

Output a single integer which is the length of the longest contiguous subarray whose sum is less than or equal to (T).## sample

3
1 2 3
6
3