CF BUDDY
← Problems·

1279B · Verse For Santa

1300 · binary search, brute force, implementation

Problem: New Year is coming! Vasya has prepared a New Year's verse and wants to recite it in front of Santa Claus.

Vasya's verse contains nn parts. It takes aia_i seconds to recite the ii-th part. Vasya can't change the order of parts in the verse: firstly he recites the part which takes a1a_1 seconds, secondly — the part which takes a2a_2 seconds, and so on. After reciting the verse, Vasya will get the number of presents equal to the number of parts he fully recited.

Vasya can skip at most one part of the verse while reciting it (if he skips more than one part, then Santa will definitely notice it).

Santa will listen to Vasya's verse for no more than ss seconds. For example, if s=10s = 10, a=[100,9,1,1]a = [100, 9, 1, 1], and Vasya skips the first part of verse, then he gets two presents.

Note that it is possible to recite the whole verse (if there is enough time).

Determine which part Vasya needs to skip to obtain the maximum possible number of gifts. If Vasya shouldn't skip anything, print 0. If there are multiple answers, print any of them.

You have to process tt test cases.

Input Format: The first line contains one integer tt (1t1001 \le t \le 100) — the number of test cases.

The first line of each test case contains two integers nn and ss (1n105,1s1091 \le n \le 10^5, 1 \le s \le 10^9) — the number of parts in the verse and the maximum number of seconds Santa will listen to Vasya, respectively.

The second line of each test case contains nn integers a1,a2,,ana_1, a_2, \dots, a_n (1ai1091 \le a_i \le 10^9) — the time it takes to recite each part of the verse.

It is guaranteed that the sum of nn over all test cases does not exceed 10510^5.

Output Format: For each test case print one integer — the number of the part that Vasya needs to skip to obtain the maximum number of gifts. If Vasya shouldn't skip any parts, print 0.

Note: In the first test case if Vasya skips the second part then he gets three gifts.

In the second test case no matter what part of the verse Vasya skips.

In the third test case Vasya can recite the whole verse.

Sample Cases

Case 1

Input

3
7 11
2 9 1 3 18 1 4
4 35
11 9 10 7
1 8
5

Output

2
1
0

Similar problems

00:00:00
Loading editor…
Welcome! I'm your coding tutor for this problem. Use the chips below to reveal stored hints or get AI feedback on your code. I'll guide you step by step — never giving away the solution.

Sign in to unlock AI tutor feedback