2662One Stroke

2662   One Stroke

题目描述

    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? 

输入格式:

    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. 

输出格式:

    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. 

输入样例 复制
1
5 6 
2 3 4 1 7
输出样例 复制
3

说明

1
17
通过提交
时空限制2000ms/1280mb
题目来源数据结构实验与竞赛训练
评测方式在线评测
题目类型
难        度