 Timer is Running

Maximum sum of subarray less than or equal to x
##### Submissions: 2021   Accuracy: 23.68%   Difficulty: Easy   Marks: 2

Given an array of integers and a number x. We have to find sum of subarray having maximum sum less than or equal to given value of x.

Input:
The first line of input contains an integer T denoting the number of test cases. The first line of each test case consists of an integer n. Next line of each test case consists of n spaced integers.The next line consists of an integer x.

Output:
Print the maximum sum of any subarray that is less than or equal to x.

Constraints:
1<=T<=100
1<=n<=1000
1<=a[i],x<=100000

Example:
Input:

2
5
1 2 3 4 5
11
5
2 4 6 8 10
7

Output:
10
6

#### ** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Saksham Ashtputre
Author: saksham0751

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.