306966: CF1279B. Verse For Santa

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Verse For Santa

题意翻译

### 题意简述 给定正整数 $n$,$s$ 和长为 $n$ 的整数数列 $a_1,a_2,...,a_n$。 求一个最大的 $i$,使得存在一个 $j$ 满足 $1\leq j\leq i$,让 $(\sum_{k=1}^{i} a_k) -a_j \leq s$ 。 ### 输入格式 **本题有多组数据**。 第一行一个正整数 $t(1\leq t\leq 100)$,表示数据组数。 对于每组数据,第一行两个正整数 $n$,$s(1\leq n \leq 10^5,1\leq s \leq 10^9)$。 接下来一行 $n$ 个整数 $a_1,a_2,...,a_n(1\leq a_i \leq 10^9)$。 保证输入的 $n$ 之和不超过 $10^5$。 ### 输出格式 对于每组数据,输出 $j$,意义如题意所述。如果存在多个 $j$ 输出任意一个。 特殊的,如果 $\sum_{i=1}^{n} a_i \leq s$,输出 $0$。

题目描述

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 $ a_i $ 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 $ a_1 $ seconds, secondly — the part which takes $ a_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 $ 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.

输入输出格式

输入格式


The first line contains one integer $ t $ ( $ 1 \le t \le 100 $ ) — the number of test cases. The first line of each test case contains two integers $ n $ and $ s $ ( $ 1 \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 $ n $ integers $ a_1, a_2, \dots, a_n $ ( $ 1 \le a_i \le 10^9 $ ) — 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 $ 10^5 $ .

输出格式


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.

输入输出样例

输入样例 #1

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

输出样例 #1

2
1
0

说明

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.

Input

题意翻译

### 题意简述 给定正整数 $n$,$s$ 和长为 $n$ 的整数数列 $a_1,a_2,...,a_n$。 求一个最大的 $i$,使得存在一个 $j$ 满足 $1\leq j\leq i$,让 $(\sum_{k=1}^{i} a_k) -a_j \leq s$ 。 ### 输入格式 **本题有多组数据**。 第一行一个正整数 $t(1\leq t\leq 100)$,表示数据组数。 对于每组数据,第一行两个正整数 $n$,$s(1\leq n \leq 10^5,1\leq s \leq 10^9)$。 接下来一行 $n$ 个整数 $a_1,a_2,...,a_n(1\leq a_i \leq 10^9)$。 保证输入的 $n$ 之和不超过 $10^5$。 ### 输出格式 对于每组数据,输出 $j$,意义如题意所述。如果存在多个 $j$ 输出任意一个。 特殊的,如果 $\sum_{i=1}^{n} a_i \leq s$,输出 $0$。

加入题单

算法标签: