menu: each row is a section (soups, mains, drinks, …) and holds the prices of its dishes in non-decreasing order.
A meal is exactly one dish from every section, and its price is the sum of the chosen dishes. Two meals are different if at least one section uses a different dish (a different position in the row), even when the prices match.
Sort all possible meals by price and return the price of the k-th cheapest one (1-based).menu=[[2, 5, 6], [1, 3, 4]], k=3 → 6
The cheapest meals are 2+1=3, 2+3=5, 2+4=6, 5+1=6, 6+1=7, … The third cheapest costs 6.
menu=[[7], [3], [10]], k=1 → 20
Every row has a single dish, so there is just one meal: 7+3+10=20.
menu=[[1, 1, 8], [2, 6, 9], [1, 4, 4]], k=5 → 7
The cheapest meals cost 4, 4, 7, 7, 7, … so the fifth one costs 7. Different meals with the same price count separately.
n, 1 ≤ n ≤ 40menu[i] is sorted in non-decreasing ordermenu=[[2, 5, 6], [1, 3, 4]], k=3
6
Run checks the first 3 tests in your browser. Submit checks all 82 tests on the server, hidden ones included.