BETA

Difficulty Level: Easy

Submissions: 831 Accuracy:

16.85%

Maximum sum of subarray less than or equal to x
     

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

Set Default Code

					   
It is recommended to 'Compile & Test' your code before clicking 'Submit'!

Compilation/Execution Result:

Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.