cswork / OA打开练习工作台

AmazonOA #113

Cleanup Dataset

估计中等可在线判题

考点(AI 标注)哈希计数贪心调度

Each time, choose any two positions and delete them; the cost is x if the characters are equal and y otherwise. Given a string of even length, find the minimum total cost to delete everything.

输入格式

The first line contains the string dataset (even length 2..100000), and the second line contains x y (1..10000).

输出格式

Output a single integer answer.

样例 1

输入:

aaabca
3 2

输出:

7

样例 2

输入:

ouio
2 4

输出:

6

样例 3

输入:

aabb
2 7

输出:

4

样例说明

Example 1: the four a characters must form at least one pair among themselves, and the other two pairs are mixed, for a total of 3+2+2=7. Example 2: pair oo and ui, for a total of 2+4=6. Example 3: delete aa and bb separately, at a cost of 4.