PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GD0000058. Rồng của Loowater (Loowater)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Rồng của Loowater (Loowater)
Loowater
Source: Kattis
Version: Phuoc Hung OJ Extended
Problem Statement
The Loowater dragon has heads of diameters . There are knights of heights costing coins each. A knight can cut at most one head whose diameter does not exceed the knight height. Hire knights at most once and minimize total cost, or report impossibility.
Input
Line 1: . The next lines contain head diameters. The next lines contain knight heights.
Output
Print the minimum cost if feasible, otherwise exactly Loowater is doomed!.
Subtasks
- Subtask 1 (20 points): ; for all valid indices.
- Subtask 2 (30 points): ; for all valid indices.
- Subtask 3 (50 points): ; for all valid indices.
Examples
Input
2 3
5
4
7
8
4
Output
11
Explanation
A knight of height 4 cuts the head of diameter 4 for cost 4. The head of diameter 5 then needs the knight of height 7, costing 7. Minimum total 11.