1203: One Stroke

Time Limit: 2 Sec  Memory Limit: 1280 MB
Submit: 264  Solved: 56
[Submit][Status][Web Board]

Description

There is a complete binary tree which includes n nodes. Each node on the tree has a weight w, each edge on the tree is directed from the parent node to the child node. Give you a pen, draw from the any node along the directed edge at one stroke. It is required that the sum of those drawn nodes’ s weight is no more than k. How many node can be drawn at most in one stroke?

Input

The first line input an positive integer T(1<=T<=10)indicates the number of test cases. Next, each case occupies two lines. The first line input two positive integers n(1<=n<=10^6) and k,(1<=k<=10^9)

The second line input n integers w(1<=w <=10^3),, indicate the weight of nodes from the first level of the tree and from left to right.

Output

For each test cases, output one line with the most number of nodes can be drawn in one stroke. If any node likes this doesn’t exists, output -1.

Sample Input

1
5 6
2 3 4 1 7

Sample Output

3

HINT

 
 
 
 
 

最新文章

  1. 关于SQL的相关笔记【长期更新,只发一帖】
  2. windows phpstudy 本地添加自定义域名
  3. jQuery1.9为动态添加元素绑定事件以及获取和操作checkbox的选择属性
  4. Python学习总结14:时间模块datetime &amp; time &amp; calendar (一)
  5. javascript window.confirm确认 取消对话框实现代码小结
  6. ES6和CommonJS的区别 以及 export和module.exports的区别
  7. Linux的top命令学习【转载】
  8. selenium中的alter弹框
  9. dicom学习文章
  10. node 跨域请求设置
  11. CSS定位方法
  12. [sh]basename&amp;dirname截取路径和文件名&amp;case参数选项
  13. Linux 命令梳理
  14. python函数传入参数(默认参数、可变长度参数、关键字参数)
  15. 用Dagger2在Android中实现依赖注入
  16. SOA 解惑
  17. 【LOJ】#2268. 「SDOI2017」苹果树
  18. 【MySQL】MySQL之MySQL常用的函数方法
  19. java php 等,路径 上级路径,上上级路径表示方法
  20. [AGC003F] Fraction of Fractal 矩阵快速幂

热门文章

  1. ng-disabled的使用
  2. Quartz使用总结(转发:http://www.cnblogs.com/drift-ice/p/3817269.html)
  3. Tips for Unix/Linux
  4. iOS AVPlayer 学习
  5. MySQL 数据库怎样把一个表的数据插入到另一个表
  6. 配置树莓派3和局域网NTP服务器实现内网时间校准
  7. [转]u盘读不出来怎么办大汇总
  8. Logger日志级别说明及设置方法、说明
  9. 关于IIntelliJ IDEA(2017)安装和破解
  10. 查看git安装目录