Problem 1862 --One Stroke

1862: One Stroke

"
Time Limit $2$ 秒/Second(s) Memory Limit $512$ 兆字节/Megabyte(s)
提交总数 $4$ 正确数量 $2$
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签

    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

推荐代码 查看1862 所有题解 上传题解视频得图灵币

本题记录 用 户(点击查看用户) 运行号(点击购买题解) 时 间
算法最快[$310 $ms] sqrjy 609826 2020-08-08 22:22:27
内存最少[$5992 $KB] sqrjy 609826 2020-08-08 22:22:27
第一AC 淡意的温柔 588184 2020-05-28 11:06:03
第一挑战 AOJ大管家 84152 2017-04-26 12:51:58

赛题来源/所属竞赛 NA N/A

竞赛编号 竞赛名称 竞赛时间 访问比赛