Wood Jojo is a carpenter and now he needs X metres of wood. He is now in
Question:
Wood Jojo is a carpenter and now he needsXmetres of wood. He is now in a forest withNtrees with integer height in metres, A1, A2, . . . , AN. He has a special cutting device. The device can be set to a certain heightH. After that, it can cuts all the tree that has height more thanHat the same time. Then, he will collect the parts that were cut off. Since he is lazy, he only wants to use the cutting device once. Help him to find the maximum integer heightHfor the device such that the sum of parts that is cut off is at leastXmeters. It is guaranteed that the sum of all of the tree heights will be more than or equal toX.
Format Input The first line consist of two integers,NandX. The second line consist ofNintegers, A1, A2, . . . , AN, the height of the trees in metres.
Format Output Output 1 line which consists of an integerH, which is the maximum integer height for the device such that the sum of the parts that will be collected is at leastXmeters.
Constraints 1 N 105/ 100000 1 Ai , X 1012/ 1000000000000
Sample Input 1 (standard input)
7 10 1 1 2 3 3 3 3 |
Sample Output 1(standard output)
0 |
Sample Input 2(standard input)
7 10 2 2 2 3 3 3 3 |
Sample Output 2(standard output)
1 |
Note : Use Standard C Language, Function, and Simple Code Input and Output Must Be The Same
Q17;
AgNO3 +NaCl ---> ?
Intermediate Accounting
ISBN: 978-0176509736
10th Canadian Edition, Volume 1
Authors: Donald Kieso, Jerry Weygandt, Terry Warfield, Nicola Young,