#BS0000009. Sơn phòng (Room Painting)
Sơn phòng (Room Painting)
Room Painting
Source: Kattis
Version: Phuoc Hung OJ Extended
Problem Statement
A paint shop offers fixed can sizes and has an unlimited number of cans of each size. You need different colours. For each required amount , you buy exactly one can, and it must be large enough.
For every colour, choose the smallest offered can size with . The wasted paint is .
Let be the chosen can size for colour . The required total waste is:
Input
The first line contains and .
The next lines contain the offered can sizes in microlitres.
The next lines contain the required amounts in microlitres.
For every requirement, at least one offered can is large enough.
Output
Print the total number of wasted microlitres.
Subtasks
- Subtask 1 — 20%: .
- Subtask 2 — 30%: .
- Subtask 3 — 50%: ; every can holds at most litres, i.e. at most microlitres.
Examples
Input
3 2
5
7
9
6
8
Output
2
Explanation
Requirement uses can and wastes . Requirement uses can and wastes , for a total of .