CF1279B.Verse For Santa
普及-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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.
新年即将到来!瓦西娅准备了一首新年诗歌,打算在圣诞老人面前朗诵。
瓦西娅的诗歌包含 n 个部分。朗诵第 i 个部分需要 ai 秒。瓦西娅不能改变诗歌各部分的顺序:他首先朗诵耗时 a1 秒的部分,其次朗诵耗时 a2 秒的部分,依此类推。朗诵完诗歌后,瓦西娅获得的礼物数量等于他完整朗诵的部分数。
在朗诵过程中,瓦西娅最多可以跳过诗歌中的一个部分(若跳过超过一个部分,则圣诞老人一定会察觉)。
圣诞老人最多只会听瓦西娅朗诵 s 秒。例如,若 s=10,a=[100,9,1,1],且瓦西娅跳过了诗歌的第一个部分,则他可获得两份礼物。
注意:若时间充足,瓦西娅也可以选择不跳过任何部分,完整朗诵整首诗歌。
请确定瓦西娅应跳过哪一部分,才能获得最多的礼物。若不应跳过任何部分,请输出 0;若存在多种可行方案,输出任意一种即可。
你需要处理 t 组测试用例。
输入格式
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.
第一行包含一个整数 t(1≤t≤100)——测试用例的数量。
每个测试用例的第一行包含两个整数 n 和 s(1≤n≤105,1≤s≤109)——分别为诗句的段落数和圣诞老人愿意听 Vasya 表演的最长时间(单位:秒)。
每个测试用例的第二行包含 n 个整数 a1,a2,…,an(1≤ai≤109)——分别为朗诵诗句各段所需的时间。
保证所有测试用例的 n 值之和不超过 105。
输出格式
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.
对于每个测试用例,输出一个整数——即瓦西娅需要跳过的部分的编号,以获得最多的礼物数量。如果瓦西娅不应跳过任何部分,则输出 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.
在第一个测试用例中,如果瓦西娅跳过第二部分,他将获得三份礼物。
在第二个测试用例中,无论瓦西娅跳过诗的哪一部分。
在第三个测试用例中,瓦西娅可以完整地朗诵整首诗。
输入解题思路,AI测评打分。不知道怎么写?