You are on page 1of 1

Task: Trees

A lumberjack needs to cut a certain amount of wood and has a saw that he can adjust
to cut anything which integer height (in meters). Since the saw only cuts wood above
the height at which it is set, the higher the saw, the less wood will be cut. Since the
logger cares about the environment, he does not want to cut down more wood than
he needs. Write a program that determines the highest possible integer height of the
saw, so that the woodcutter gets enough wood (assuming there is always enough
wood).
Input: From standard input, the number of trees in the forest n (1 ≤ n ≤ 105) is
loaded, followed by an array of the heights of each wood (a series of natural numbers
between 1 and 10000, each in a separate order). After that, the quantity is also
loaded of chopped wood (since all the trunks are of the same thickness, the quantity
is measured in meters of the height of the cut trees).
Output: Print the requested maximum integer height of the saw to the standard
output.
Input: Output:
5 18
24
21
19
14
22
14

You might also like