You have three columns of coins where each coin has the same diameter, but they may vary in height. The height of the coin is the same as its value .
Example : 1 Re. coin will have its height as 1 unit.
You can change the height of a column by removing and discarding its topmost coin any number of times.
Find the maximum possible height of the columns such that all of the columns are exactly the same height.
This means you must remove zero or more coins from the top of zero or more of the three columns until they're all the same height, then print the height.
The removals must be performed in such a way as to maximize the height.
Note: An empty column is still a column.
Input Format
The first line contains three space-separated integers n1, n2, and n3 describing the respective number of coins in columns 1, 2, and 3. The subsequent lines describe the respective heights of each coin in a column from top to bottom:
Constraints
Output Format
Print a single integer denoting the maximum height at which all column will be of equal height.
Initially the heights of the columns 1, 2 and 3 are 8,9 and 7 respectively, which are not same.
If we remove a coin of height 3 from top of column 1, coin of height 4 from top of column 2 and 2 coins of height 1 from top of column 3, the heights of all the three columns become equal with height 5.
All three columns now have height = 5. Thus, we print 5 as our answer.