Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Wood Jojo is a carpenter and now he needs X metres of wood. He is now in a forest with N trees with integer height

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 ---> ?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

Heres a Python code that solves the problem of finding the maximum integer height H for the cutting ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intermediate Accounting

Authors: Donald Kieso, Jerry Weygandt, Terry Warfield, Nicola Young,

10th Canadian Edition, Volume 1

978-1118735329, 9781118726327, 1118735323, 1118726324, 978-0176509736

More Books

Students also viewed these Finance questions

Question

Identify the physical and cognitive changes of adulthood.

Answered: 1 week ago