Question
Market Hunt
In a lively bazaar, explorer Lila stumbles upon food stalls with unlisted prices.
She finds k price lists on the market’s site. Lila knows the true price of an item is its highest listed value across all lists.
The most accurate list has the most correct prices; if tied, it’s the one with the highest average price.
Help Lila identify the most updated price list to guide her shopping.
Input
The first line contains integers k and m that denote the number of lists and the number of items on each list respectively.
The next k line each contains m integers represented as Aij, the jth price on the ith list.
The next k line each contains m integers represented as Aij, the jth price on the ith list.
Output
Print a single integer identifying the most updated price list to guide her shopping.
Example
Sample input
3 4
1 2 1 10
3 2 3 4
1 3 3 2
Sample output
2
Description
There are 4 items in this example. The maximum price for the first three items is 3 and for the last item is 10. First menu has only one good price which is the last one, Second menu has 2 good prices on it, which are first and third items and the last menu, has 2 good prices too.
So between second and third menus, we have to compare averages. Average of second menu is (3 + 2 + 3 + 4) / 4 = 3 and average of third menu is (1 + 3 + 3 + 2) / 4 = 2.25 so the second menu would be the answer.
3 4
1 2 1 10
3 2 3 4
1 3 3 2
Sample output
2
Description
There are 4 items in this example. The maximum price for the first three items is 3 and for the last item is 10. First menu has only one good price which is the last one, Second menu has 2 good prices on it, which are first and third items and the last menu, has 2 good prices too.
So between second and third menus, we have to compare averages. Average of second menu is (3 + 2 + 3 + 4) / 4 = 3 and average of third menu is (1 + 3 + 3 + 2) / 4 = 2.25 so the second menu would be the answer.