#abc308b. B - Default Price

B - Default Price

Score : 200200 points

问题描述

高桥在一家寿司店吃了 NN 盘寿司。第 ii 盘寿司的颜色用字符串 CiC_i 表示。

每种寿司的价格与其盘子颜色相对应。对于每个 i=1,,Mi=1,\ldots,M,颜色表示为字符串 DiD_i 的盘子上的寿司价值 PiP_i 日元/盘(日元是日本的货币)。如果颜色与 D1,,DMD_1,\ldots,D_M 中任何一个都不吻合,则该寿司价值 P0P_0 日元/盘。

请计算高桥所吃寿司的总价格。

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

Problem Statement

Takahashi ate NN plates of sushi at a sushi restaurant. The color of the ii-th plate is represented by a string CiC_i.

The price of a sushi corresponds to the color of the plate. For each i=1,,Mi=1,\ldots,M, the sushi on a plate whose color is represented by a string DiD_i is worth PiP_i yen a plate (yen is the currency of Japan). If the color does not coincide with any of D1,D_1,\ldots, and DMD_M, it is worth P0P_0 yen a plate.

Find the total amount of the prices of sushi that Takahashi ate.

Constraints

  • 1N,M1001\leq N,M\leq 100
  • CiC_i and DiD_i are strings of length between 11 and 2020, inclusive, consisting of lowercase English letters.
  • D1,D_1,\ldots, and DMD_M are distinct.
  • 1Pi100001\leq P_i\leq 10000
  • NN, MM, and PiP_i are integers.

Input

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

NN MM

C1C_1 \ldots CNC_N

D1D_1 \ldots DMD_M

P0P_0 P1P_1 \ldots PMP_M

Output

Print the answer as an integer.

Sample Input 1

3 2
red green blue
blue red
800 1600 2800

Sample Output 1

5200

A blue plate, red plate, and green plate are worth P1=1600P_1 = 1600, P2=2800P_2 = 2800, and P0=800P_0 = 800 yen, respectively.

The total amount of the prices of the sushi that he ate is 2800+800+1600=52002800+800+1600=5200 yen.

Sample Input 2

3 2
code queen atcoder
king queen
10 1 1

Sample Output 2

21

update @ 2024/3/10 08:43:37