欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1791G1.Teleporters (Easy Version)
Teleporters (Easy Version)
The only difference between the easy and hard versions are the locations you can teleport to.
Consider the points on the number line. There is a teleporter located on each of the points . At point , you can do the following:
- Move left one unit: it costs coin.
- Move right one unit: it costs coin.
- Use a teleporter at point , if it exists: it costs coins. As a result, you teleport to point . Once you use a teleporter, you can't use it again.
You have coins, and you start at point . What's the most number of teleporters you can use?
Input
The input consists of multiple test cases. The first line contains an integer () — the number of test cases. The descriptions of the test cases follow.
The first line of each test case contains two integers and (; ) — the length of the array and the number of coins you have respectively.
The following line contains space-separated integers () — the costs to use the teleporters.
It is guaranteed that the sum of over all test cases does not exceed .
Output
For each test case, output the maximum number of teleporters you can use.
Note
In the first test case, you can move one unit to the right, use the teleporter at index and teleport to point , move two units to the right and use the teleporter at index . You are left with 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 , then go six units right and use the teleporter at index to go to . The total cost will be . You are left with coins, but it is not enough to reach any other teleporter and use it so the answer is .
In the third test case, you don't have enough coins to use any teleporter, so the answer is zero.
Samples
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
2
2
0
1
2
2
1
1
1
2
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |