CF1697A.Parkway Walk

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are walking through a parkway near your house. The parkway has n+1n+1 benches in a row numbered from 11 to n+1n+1 from left to right. The distance between the bench ii and i+1i+1 is aia_i meters.

Initially, you have mm units of energy. To walk 11 meter of distance, you spend 11 unit of your energy. You can't walk if you have no energy. Also, you can restore your energy by sitting on benches (and this is the only way to restore the energy). When you are sitting, you can restore any integer amount of energy you want (if you sit longer, you restore more energy). Note that the amount of your energy can exceed mm .

Your task is to find the minimum amount of energy you have to restore (by sitting on benches) to reach the bench n+1n+1 from the bench 11 (and end your walk).

You have to answer tt independent test cases.

输入格式

The first line of the input contains one integer tt ( 1t1001 \le t \le 100 ) — the number of test cases. Then tt test cases follow.

The first line of the test case contains two integers nn and mm ( 1n1001 \le n \le 100 ; 1m1041 \le m \le 10^4 ).

The second line of the test case contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n ( 1ai1001 \le a_i \le 100 ), where aia_i is the distance between benches ii and i+1i+1 .

输出格式

For each test case, print one integer — the minimum amount of energy you have to restore (by sitting on benches) to reach the bench n+1n+1 from the bench 11 (and end your walk) in the corresponding test case.

输入输出样例

  • 输入#1

    3
    3 1
    1 2 1
    4 5
    3 3 5 2
    5 16
    1 2 3 4 5

    输出#1

    3
    8
    0

说明/提示

In the first test case of the example, you can walk to the bench 22 , spending 11 unit of energy, then restore 22 units of energy on the second bench, walk to the bench 33 , spending 22 units of energy, restore 11 unit of energy and go to the bench 44 .

In the third test case of the example, you have enough energy to just go to the bench 66 without sitting at all.

首页