You are given two integer arrays, skill and mana, of length n and m respectively. In a laboratory, n wizards must brew m potions in order.
Each potion has a mana capacity mana[j] and must pass through all the wizards sequentially to be brewed properly. The time taken by the i-th wizard on the j-th potion is time[i][j] = skill[i] * mana[j].
Important: Since the brewing process is delicate, a potion must be passed to the next wizard immediately after the current wizard completes their work. This means the timing must be synchronized so that each wizard begins working on a potion exactly when it arrives.
Return the minimum amount of time required for all potions to be brewed properly.
Input & Output
Constraints
- 1 ≤ n, m ≤ 103
- 1 ≤ skill[i], mana[j] ≤ 104