CF1791G1.Teleporters (Easy Version)
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
The only difference between the easy and hard versions are the locations you can teleport to.
Consider the points 0,1,…,n on the number line. There is a teleporter located on each of the points 1,2,…,n . At point i , you can do the following:
- Move left one unit: it costs 1 coin.
- Move right one unit: it costs 1 coin.
- Use a teleporter at point i , if it exists: it costs ai coins. As a result, you teleport to point 0 . Once you use a teleporter, you can't use it again.
You have c coins, and you start at point 0 . What's the most number of teleporters you can use?
输入格式
The input consists of multiple test cases. The first line contains an integer t ( 1≤t≤1000 ) — the number of test cases. The descriptions of the test cases follow.
The first line of each test case contains two integers n and c ( 1≤n≤2⋅105 ; 1≤c≤109 ) — the length of the array and the number of coins you have respectively.
The following line contains n space-separated integers a1,a2,…,an ( 1≤ai≤109 ) — the costs to use the teleporters.
It is guaranteed that the sum of n over all test cases does not exceed 2⋅105 .
输出格式
For each test case, output the maximum number of teleporters you can use.
输入输出样例
输入#1
10 5 6 1 1 1 1 1 8 32 100 52 13 6 9 4 100 35 1 1 5 4 5 4 3 2 1 5 9 2 3 1 4 1 5 8 2 3 1 4 1 4 3 2 3 4 1 4 9 5 4 3 3 2 14 7 5 5 600000000 500000000 400000000 300000000 200000000 100000000
输出#1
2 2 0 1 2 2 1 1 1 2
说明/提示
In the first test case, you can move one unit to the right, use the teleporter at index 1 and teleport to point 0 , move two units to the right and use the teleporter at index 2 . You are left with 6−1−1−2−1=1 coins you don't have enough coins to use another teleporter. You have used two teleporters, so the answer is two.
In the second test case, you go four units to the right and use the teleporter to go to 0 , then go six units right and use the teleporter at index 6 to go to 0 . The total cost will be 4+6+6+4=20 . You are left with 12 coins, but it is not enough to reach any other teleporter and use it so the answer is 2 .
In the third test case, you don't have enough coins to use any teleporter, so the answer is zero.