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

Bài tập thuộc lộ trình

1 lộ trình

Rồng của Loowater (Loowater)

Loowater

Source: Kattis

Version: Phuoc Hung OJ Extended

Problem Statement

The Loowater dragon has nn heads of diameters did_i. There are mm knights of heights hjh_j costing hjh_j 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: n,mn,m. The next nn lines contain head diameters. The next mm lines contain knight heights.

Output

Print the minimum cost if feasible, otherwise exactly Loowater is doomed!.

Subtasks

  • Subtask 1 (20 points): 1≤n,m≤51\le n,m\le 5; 1≤di,hj≤200001\le d_i,h_j\le 20000 for all valid indices.
  • Subtask 2 (30 points): 1≤n,m≤10001\le n,m\le 1000; 1≤di,hj≤200001\le d_i,h_j\le 20000 for all valid indices.
  • Subtask 3 (50 points): 1≤n,m≤200001\le n,m\le 20000; 1≤di,hj≤200001\le d_i,h_j\le 20000 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.