Tom's Kitchen
Time limit2sMemory limit512 MB
Pick a subset of chefs so each meal gets at least K chefs working positive whole hours that sum exactly to A_i, minimizing the paid idle hours.
Problem
Tom's Kitchen is a very popular restaurant. One reason for its popularity is that every meal is prepared by at least different chefs. Today, there are meals to prepare, and meal needs hours of work.
Tom can hire chefs. Chef works at most hours. Even when a chef works less than that, the chef is paid for the full hours. A chef can work on several meals for different amounts of time. A meal is prepared properly only if at least chefs take part in preparing it and the total time they spend is exactly . When a chef takes part in preparing a meal, the chef always works a positive integer number of hours.
Tom needs to choose the subset of chefs that minimizes the total number of hours the chefs are paid for without working.
Input
The first line contains the integers , , and . The second line contains integers . The third line contains integers .
Output
Print the minimum total number of hours the chefs are paid for without working when Tom chooses the optimal subset. If there is no way to prepare all meals according to the rules, print "Impossible".