Tom’s Kitchen

M명의 요리사 중 일부를 고용해, 각 식사 Ai를 최소 K명의 요리사가 양의 정수 시간으로 나누어 만들도록 하면서 놀고 받는 임금 시간의 합을 최소화한다.

어려움8동적 계획법그리디조합론구현아직 제출이 없습니다시간 제한2초메모리 제한512 MB

문제

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 K different chefs. Today, there are N meals to be prepared, with meal i needing Ai hours of work.

There are M chefs which Tom can hire to prepare all the meals but the chef j will work at most Bj hours. Additionally, even when he works less, he still wants to be paid for the full Bj hours. A chef can work on several meals for different amounts of time, but any meal will be properly prepared only if at least K chefs take part in preparing it and the total time they spend is exactly Ai. 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 minimized.

입력

The first line contains the integers N, M, and K.

The second line contains N integers Ai and the third line M integers Bj.

출력

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 N meals according to the rules described above, output “Impossible”.