Dolce Vita
Turbulent times are coming, so you decided to buy sugar in advance. There are n shops around that sell sugar: the i-th shop sells one pack of sugar for ai coins, but only one pack to one customer each day. So in order to buy several packs, you need to visit several shops.
Another problem is that prices are increasing each day: during the first day the cost is ai, during the second day cost is ai+1+1, during the third day — ai+2+2 and so on for each shop i.
On the contrary, your everyday budget is only x coins. In other words, each day you go and buy as many packs as possible with total cost not exceeding x. Note that if you don't spend some amount of coins during a day, you can't use these coins during the next days.
Eventually, the cost for each pack will exceed x, and you won't be able to buy even a single pack. So, how many packs will you be able to buy till that moment in total?
The first line contains a single integer t (1≤t≤10001≤≤1000) — the number of test cases. Next t cases follow.
The first line of each test case contains two integers n and x (1≤n≤2⋅1051≤≤2⋅105; 1≤x≤1091≤≤109) — the number of shops and your everyday budget.
The second line of each test case contains n integers a1,a2,…,an1,2,…, (1≤ai≤1091≤≤109) — the initial cost of one pack in each shop.
It's guaranteed that the total sum of n doesn't exceed 2⋅1052⋅105.
For each test case, print one integer — the total number of packs you will be able to buy until prices exceed your everyday budget.
In the first test case,
- Day 1: prices are [2,1,2] You can buy all 33 packs, since 2+1+2≤7
- Day 2: prices are [3,2,3] You can't buy all 33 packs, since 3+2+3>7, so you buy only 22 packs.
- Day 3: prices are [4,3,4] You can buy 22 packs with prices 4 and 3.
- Day 4: prices are [5,4,5] You can't buy 22 packs anymore, so you buy only 1 pack.
- Day 5: prices are [6,5,6] You can buy 1 pack.
- Day 6: prices are [7,6,7] You can buy 1 pack.
- Day 7: prices are [8,7,8] You still can buy 11 pack of cost 77.
- Day 8: prices are [9,8,9]. Prices are too high, so you can't buy anything.
In the second test case, prices are too high even at the first day, so you can't buy anything.
In the third test case, you can buy only one pack at day one.
__EOF__

本文链接:https://www.cnblogs.com/o-Sakurajimamai-o/p/17513358.html
关于博主:评论和私信会在第一时间回复。或者直接私信我。
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角【推荐】一下。您的鼓励是博主的最大动力!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具