#TP0000029. Rồng xứ Loowater (Dragon of Loowater)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Rồng xứ Loowater (Dragon of Loowater)
Dragon of Loowater
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
A dragon in Loowater has heads; head has diameter centimetres. The kingdom has knights, and knight is centimetres tall.
A knight can chop off a head only if its diameter is no greater than the knight's height. Each knight can be hired at most once, and hiring knight costs exactly gold coins. Find the minimum total cost of chopping off every head. If this is impossible, print exactly Loowater is doomed!.
Input
- The first line contains , the number of dragon heads and the number of knights.
- Each of the next lines contains an integer , the diameter in centimetres of head .
- Each of the final lines contains an integer , the height in centimetres of knight .
Output
Print one integer, the minimum cost; if the task is impossible, print exactly Loowater is doomed!.
Subtasks
- Subtask 1 (20 points): ; for every element.
- Subtask 2 (30 points): ; for every element.
- Subtask 3 (50 points): ; for every element.
Examples
Input
2 3
5
4
7
8
4
Output
11
Explanation
The dragon heads have diameters and . The knight of height can chop off the size- head and costs coins. The knight of height can chop off the size- head and costs coins. The total is . Using the knight of height would be more expensive.