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 n parts. It takes ai seconds to recite the i-th part. Vasya can’t change the order of parts in the verse: firstly he recites the part which takes a1 seconds, secondly — the part which takes a2 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 s seconds. For example, if s=10, 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 t test cases.
Input
The first line contains one integer t (1≤t≤100) — the number of test cases.
The first line of each test case contains two integers n and s (1≤n≤105,1≤s≤109) — 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 n integers a1,a2,…,an (1≤ai≤109) — the time it takes to recite each part of the verse.
It is guaranteed that the sum of n over all test cases does not exceed 105.
Output
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.
Example
inputCopy
3
7 11
2 9 1 3 18 1 4
4 35
11 9 10 7
1 8
5
outputCopy
2
1
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.
t组输入,每组第一行两个数 n,s n表示有n篇文章,s表示圣诞老人听的时间,
接下一行有n个数,a[1]…a[n] 每个数表示一篇文章所花的时间。求删掉哪个文章圣诞老人听的文章最多 ,只能删掉一篇文章。
找最大的数并且前面的数的和还[0,s]的范围内
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<iostream>
#include<vector>
#include<set>
#include<stack>
#include<map>
#include<queue>
typedef unsigned long long ull;
typedef long long ll;
using namespace std;
const int N=1e5+5;
const int prime=2333317;
const int INF=0x3f3f3f3f3f;
int a[N];
ll sum[N];
int main()
{
int t;
scanf("%d",&t);
while(t--)
{
memset(sum,0,sizeof(sum));
int n,s;
scanf("%d%d",&n,&s);
int maxx=-9999;
int node;
for(int i=1;i<=n;i++)
{
scanf("%d",&a[i]);
sum[i]=sum[i-1]+a[i];
}
if(sum[n]<=s)
{
printf("0\n");
continue;
}
for(int i=1;i<=n;i++)
{
if(maxx<a[i]&&sum[i-1]<=s)
{
maxx=a[i];
node=i;
}
}
printf("%d\n",node);
}
return 0;
}