Under construction

Still being built. Things may change

Tom's Kitchen

Time limit2sMemory limit512 MB

Summary
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.
Level

Hard8 of 10

Topics
Graph, Greedy
Solved
No attempts yet

Problem

Tom's Kitchen is a very popular restaurant. One reason for its popularity is that every meal is prepared by at least KK different chefs. Today, there are NN meals to prepare, and meal ii needs AiA_i hours of work.

Tom can hire MM chefs. Chef jj works at most BjB_j hours. Even when a chef works less than that, the chef is paid for the full BjB_j hours. A chef can work on several meals for different amounts of time. A meal is prepared properly only if at least KK chefs take part in preparing it and the total time they spend is exactly AiA_i. 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 NN, MM, and KK. The second line contains NN integers AiA_i. The third line contains MM integers BjB_j.

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 NN meals according to the rules, print "Impossible".

Examples3

  1. Example 1

    Input
    1 2 2
    5
    3 4
    
    Expected output
    2
    
  2. Example 2

    Input
    1 1 2
    5
    5
    
    Expected output
    Impossible
    
  3. Example 3

    Input
    3 3 3
    3 3 2
    3 3 3
    
    Expected output
    Impossible