hzau 1203 One Stroke

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

时间: 2024-09-30 12:48:19

hzau 1203 One Stroke的相关文章

HZAU 1203 One Stroke(倍增)

题目链接:http://acm.hzau.edu.cn/problem.php?id=1203 [题意]给你一颗完全二叉树每个节点都有一个权值,然后要你从上往下找一条链,值得链上权值的和<K,且节点数最大. [分析]有两种做法:一种是在树上双指针,另一种是先求一下前缀和,当到i节点时前缀和<K,更新ans,当前缀和>K,倍增向上找 使得前缀和<K的节点,更新ans. #include <bits/stdc++.h> #define inf 100000000 #defi

PAT Acute Stroke (30)

题目描述 One important factor to identify acute stroke (急性脑卒中) is the volume of the stroke core. Given the results of image analysis in which the core regions are identified in each MRI slice, your job is to calculate the volume of the stroke core. 输入描述:

TLS 协议所定义的严重错误代码是 10。Windows SChannel 错误状态是 1203

windows 2012 操作系统下面报36888/36887. 生成了一个严重警告并将其发送到远程终结点.这会导致连接终止.TLS 协议所定义的严重错误代码是 10.Windows SChannel 错误状态是 1203. 从远程终点接收到一个严重警告.TLS 协议所定义的严重警告代码为 48. 其实schannel的事件录入是分成4个等级的: Logging options The default value for Schannel event logging is 0×0000 in W

TOJ 1203: Number Sequence

1203: Number Sequence Time Limit(Common/Java):1000MS/10000MS     Memory Limit:65536KByte Total Submit: 957            Accepted:208 Description A number sequence is defined as follows: f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1) + B * f(n - 2)) mod 7. Gi

PAT-ADVANCED-1091-Acute Stroke

One important factor to identify acute stroke (急性脑卒中) is the volume of the stroke core. Given the results of image analysis in which the core regions are identified in each MRI slice, your job is to calculate the volume of the stroke core. Input Spec

ACdream 1203 - KIDx&#39;s Triangle(解题报告)

KIDx's Triangle Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others) Submit Statistic Next Problem Problem Description One day, KIDx solved a math problem for middle students in seconds! And than he created this problem. N

hdoj 1203 I NEED A OFFER! 【另类01背包】【概率背包】

题意:... 策略:动态规划. 因为是求至少能得到一个offer的概率,那我们可以反着求,求得不到一个offer的概率,最后用1减去就好了. 代码: #include<string.h> #include<stdio.h> double dp[10010]; struct node{ int a; double b; }s[10010]; int main() { int n, m, i, j; while(scanf("%d%d", &n, &

杭电 1203 I NEED A OFFER!(01背包)

http://acm.hdu.edu.cn/showproblem.php?pid=1203 I NEED A OFFER! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 15759    Accepted Submission(s): 6259 Problem Description Speakless很早就想出国,现在他已经考完了

zoj 1203 Swordfish

链接:zoj 1203 题意:输入n个城市的坐标,输出使n个城市连通的最短路线的长度 分析:通过坐标可以将两两之间的长度即权值算出,再用最小生成树的算法 不过这个题要注意输出时的格式问题,两组数据间要空一行 #include<cstdio> #include<cmath> #include<algorithm> using namespace std; int f[110],n,m; struct stu { int a,b; double c; }t[5000]; i