Codeforces Round 684 (Div. 2)
A
Buy the String
Codeforces
800
原题
←B →
翻译中…

You are given four integers $n$, $c_0$, $c_1$ and $h$ and a binary string $s$ of length $n$.

翻译中…

A binary string is a string consisting of characters $0$ and $1$.

翻译中…

You can change any character of the string $s$ (the string should be still binary after the change). You should pay $h$ coins for each change.

翻译中…

After some changes (possibly zero) you want to buy the string. To buy the string you should buy all its characters. To buy the character $0$ you should pay $c_0$ coins, to buy the character $1$ you should pay $c_1$ coins.

翻译中…

Find the minimum number of coins needed to buy the string.

翻译中…

Input

翻译中…

The first line contains a single integer $t$ ($1 \leq t \leq 10$) — the number of test cases. Next $2t$ lines contain descriptions of test cases.

翻译中…

The first line of the description of each test case contains four integers $n$, $c_{0}$, $c_{1}$, $h$ ($1 \leq n, c_{0}, c_{1}, h \leq 1000$).

翻译中…

The second line of the description of each test case contains the binary string $s$ of length $n$.

翻译中…

Output

翻译中…

For each test case print a single integer — the minimum number of coins needed to buy the string.

翻译中…

Note

翻译中…

In the first test case, you can buy all characters and pay $3$ coins, because both characters $0$ and $1$ costs $1$ coin.

翻译中…

In the second test case, you can firstly change $2$-nd and $4$-th symbols of the string from $1$ to $0$ and pay $2$ coins for that. Your string will be $00000$. After that, you can buy the string and pay $5 \cdot 10 = 50$ coins for that. The total number of coins paid will be $2 + 50 = 52$.

翻译中…

样例

Input #1
6
3 1 1 1
100
5 10 100 1
01010
5 10 1 1
11111
5 1 10 1
11111
12 2 1 10
101110110101
2 100 1 10
00
Output #1
3
52
5
10
16
22
InputCopy OutputCopy
题目信息
题号
1440A
时间限制
1 s
内存限制
256 MB
标签
模拟
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。