A2107.砍树
入门
官方
通过率:0%
时间限制:1.00s
内存限制:128MB
题目描述
伐木工人 Mirko 需要砍<math xmlns="http://www.w3.org/1998/Math/MathML">�M米长的木材。对 Mirko 来说这是很简单的工作,因为他有一个漂亮的新伐木机,可以如野火一般砍伐森林。不过,Mirko 只被允许砍伐一排树。
Mirko 的伐木机工作流程如下:Mirko 设置一个高度参数<math xmlns="http://www.w3.org/1998/Math/MathML">�H(米),伐木机升起一个巨大的锯片到高度<math xmlns="http://www.w3.org/1998/Math/MathML">�H,并锯掉所有树比<math xmlns="http://www.w3.org/1998/Math/MathML">�H高的部分(当然,树木不高于<math xmlns="http://www.w3.org/1998/Math/MathML">�H米的部分保持不变)。Mirko 就得到树木被锯下的部分。例如,如果一排树的高度分别为<math xmlns="http://www.w3.org/1998/Math/MathML">20,15,1020,15,10和<math xmlns="http://www.w3.org/1998/Math/MathML">1717,Mirko 把锯片升到<math xmlns="http://www.w3.org/1998/Math/MathML">1515米的高度,切割后树木剩下的高度将是<math xmlns="http://www.w3.org/1998/Math/MathML">15,15,1015,15,10和<math xmlns="http://www.w3.org/1998/Math/MathML">1515,而 Mirko 将从第<math xmlns="http://www.w3.org/1998/Math/MathML">11棵树得到<math xmlns="http://www.w3.org/1998/Math/MathML">55米,从第<math xmlns="http://www.w3.org/1998/Math/MathML">44棵树得到<math xmlns="http://www.w3.org/1998/Math/MathML">22米,共得到<math xmlns="http://www.w3.org/1998/Math/MathML">77米木材。
Mirko 非常关注生态保护,所以他不会砍掉过多的木材。这也是他尽可能高地设定伐木机锯片的原因。请帮助 Mirko 找到伐木机锯片的最大的整数高度<math xmlns="http://www.w3.org/1998/Math/MathML">�H,使得他能得到的木材至少为<math xmlns="http://www.w3.org/1998/Math/MathML">�M米。换句话说,如果再升高<math xmlns="http://www.w3.org/1998/Math/MathML">11米,他将得不到<math xmlns="http://www.w3.org/1998/Math/MathML">�M米木材。
输入格式
第 11 行 22 个整数 �N 和 �M, �N 表示树木的数量, �M 表示需要的木材总长度。
第 22 行 �N 个整数表示每棵树的高度。
输出格式
1 个整数,表示锯片的最高高度。
输入输出样例
输入#1
4 7 20 15 10 17
输出#1
15
说明/提示
对于 100% 的测试数据,1≤N≤106,1≤M≤2×109,树的高度 M。