#abc308f. F - Vouchers

F - Vouchers

Score : 500500 points

问题描述

你正在一家商店购买 NN 件商品。第 ii 件商品的原价为 PiP_i 日元(日本货币单位)。

你现在拥有 MM 张优惠券。你可以使用第 ii 张优惠券以 DiD_i 日元的折扣购买原价至少为 LiL_i 日元的商品。

需要注意的是,每张优惠券只能使用一次,并且对于同一件商品不能同时使用多张优惠券。

若某件商品未使用任何优惠券,则将以原价购买。请计算购买全部 NN 件商品所需的最低总价。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

You are in a store to buy NN items. The regular price of the ii-th item is PiP_i yen (the currency in Japan).

You have MM coupons. You can use the ii-th coupon to buy an item whose regular price is at least LiL_i yen at a DiD_i-yen discount.

Here, each coupon can be used only once. Besides, multiple coupons cannot be used for the same item.

If no coupon is used for an item, you will buy it for a regular price. Find the minimum possible total amount of money required to buy all the NN items.

Constraints

  • 1N,M2×1051\leq N,M\leq 2\times 10^5
  • 1Pi1091\leq P_i\leq 10^9
  • 1DiLi1091\leq D_i \leq L_i \leq 10^9
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

NN MM

P1P_1 \ldots PNP_N

L1L_1 \ldots LML_M

D1D_1 \ldots DMD_M

Output

Print the answer as an integer.

Sample Input 1

3 3
4 3 1
4 4 2
2 3 1

Sample Output 1

4

Consider using the 22-nd coupon for the 11-st item, and the 33-rd coupon for the 22-nd item.

Then, you buy the 11-st item for 43=14-3=1 yen, 22-nd item for 31=23-1=2 yen, and 33-rd item for 11 yen. Thus, you can buy all the items for 1+2+1=41+2+1=4 yen.

Sample Input 2

10 5
9 7 1 5 2 2 5 5 7 6
7 2 7 8 2
3 2 4 1 2

Sample Output 2

37

update @ 2024/3/10 08:44:50