cswork / OA打开练习工作台

AmazonOA #38

Calculate Min Cost (Password Removal)

简单可在线判题

考点(AI 标注)哈希计数字符串

You are given password, reference, and the deletion costs of the 26 lowercase letters. Delete every character in password that appears in the character set of reference; each deleted character is charged its letter's cost. Find the minimum total cost.

输入格式

The first line is password, the second line is reference, and the third line gives cost[0..25] in order. Both strings consist of lowercase English letters and have length 1..100000; each cost is 1..100. This site carries the original function parameters in a three-line stdin/stdout format.

输出格式

Output the minimum cost of deleting all characters in password that match reference.

样例 1

输入:

kkkk
k
1 1 1 1 1 1 1 1 1 1 5 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

输出:

20

样例 2

输入:

abac
ab
2 7 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

输出:

11

样例 3

输入:

abaabab
aba
2 7 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

输出:

29

样例 4

输入:

xyzzy
ab
1 82 61 8 23 18 13 28 91 50 37 48 23 22 1 4 87 94 9 44 23 2 81 76 35 86

输出:

0

样例说明

reference only determines the set of characters to delete; every matching position in password is charged separately.