#P2695. 骑士的工作

骑士的工作

Description

Each person can cut off at most one head of size not exceeding ziz_i, and it costs ziz_i coins. Find the minimum total cost.

Input Format

  • The first line contains two integers nn, mm.
  • The next nn lines each contain one integer, the size of a head.
  • The next mm lines each contain one integer ziz_i, the maximum head size the ii-th person can cut and the number of coins required.

Output Format

Output a single integer, the minimum total cost. If it is impossible, output you died!.

2 3
5 
4
7 
8
4
11

Hint

For all testdata, 1n,m2×1041 \le n, m \le 2 \times 10^4, 1zi1051 \le z_i \le 10^5.

Translated by ChatGPT 5