103081: [Atcoder]ABC308 B - Default Price

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:6 Solved:0

Description

Score : $200$ points

Problem Statement

Takahashi ate $N$ plates of sushi at a sushi restaurant. The color of the $i$-th plate is represented by a string $C_i$.

The price of a sushi corresponds to the color of the plate. For each $i=1,\ldots,M$, the sushi on a plate whose color is represented by a string $D_i$ is worth $P_i$ yen a plate (yen is the currency of Japan). If the color does not coincide with any of $D_1,\ldots$, and $D_M$, it is worth $P_0$ yen a plate.

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

Constraints

  • $1\leq N,M\leq 100$
  • $C_i$ and $D_i$ are strings of length between $1$ and $20$, inclusive, consisting of lowercase English letters.
  • $D_1,\ldots$, and $D_M$ are distinct.
  • $1\leq P_i\leq 10000$
  • $N$, $M$, and $P_i$ are integers.

Input

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

$N$ $M$
$C_1$ $\ldots$ $C_N$
$D_1$ $\ldots$ $D_M$
$P_0$ $P_1$ $\ldots$ $P_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 $P_1 = 1600$, $P_2 = 2800$, and $P_0 = 800$ yen, respectively.

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


Sample Input 2

3 2
code queen atcoder
king queen
10 1 1

Sample Output 2

21

Input

题意翻译

要购买 $N$ 个东西,这些东西根据颜色计价。第 $i$ 个东西的颜色是 $C_i$。 而已知 $M$ 种颜色的东西的价格,其中第 $i$ 种颜色为 $D_i$,价格为 $P_i$。对于未知价格的颜色,统一按 $P_0$ 计价。现在求总共需要花多少钱。 数据范围: $1\le N,M\le 100$ $1\le P_i\le 10000$ $C_i,D_i$ 都是由英文小写字母构成的字符串。 $N,M,P_i$ 都是整数。

Output

得分:200分 部分 问题描述 Takahashi在一家寿司店吃了N盘寿司。第i盘寿司的颜色用字符串C_i表示。 寿司的价格与盘子的颜色相对应。对于每个i=1, ..., M,颜色为字符串D_i的寿司每盘价值P_i日元(日元是日本的货币)。如果颜色不与D_1, ..., 和D_M中的任何一个相符,则每盘价值P_0日元。 找出Takahashi吃的寿司的总价。 部分 约束条件 * 1≤N,M≤100 * C_i和D_i是长度在1到20之间的字符串,由小写英文字母组成。 * D_1, ..., 和D_M是不同的。 * 1≤P_i≤10000 * N,M和P_i是整数。 部分 输入 输入通过标准输入以以下格式给出: N M C_1 ... C_N D_1 ... D_M P_0 P_1 ... P_M 部分 输出 将答案作为整数打印。 部分 样例输入1 3 2 red green blue blue red 800 1600 2800 部分 样例输出1 5200 一个blue盘,red盘和green盘分别价值P_1 = 1600,P_2 = 2800和P_0 = 800日元。 他吃的寿司的总价是2800+800+1600=5200日元。 部分 样例输入2 3 2 code queen atcoder king queen 10 1 1 部分 样例输出2 21

HINT

m种颜色,价格分别是p1,p2...,无此颜色价格为p0,n种颜色总价是多少?

加入题单

算法标签: