Tom's Kitchen#9622

Tom's Kitchen

1 segundo
128 megabytes
Difícil (≈1650)

Tom's Kitchen is a very popular restaurant. One of the reasons for its popularity is that every single meal is prepared by at least different chefs. Today, there are meals to be prepared, with meal needing a_i hours of work.

There are chefs which Tom can hire to prepare all the meals but the chef will work at most b_j hours. Additionally, even when he works less, he still wants to be paid for the full b_j hours. A chef can work on several meals for different amounts of time, but any meal will be properly prepared only if at least chefs take part in preparing it and the total time they spend is exactly a_i. When a chef takes part in preparing a meal, he always works on it some positive integer number of hours.

Tom needs help in choosing the optimal subset of chefs such that the sum of hours where the chefs are getting paid without working is minimised.

Entrada

First line contains integers , and . Second line contains integers a_i and the third line integers b_j.

Salida

The only line should contain the number of hours the chefs spend not working but still getting paid when Tom chooses the optimal subset to hire. If there is no way to prepare all the meals according to the rules described above, output "Impossible".

Ejemplos

Ejemplo 1

Loading
Loading