{"trustable":true,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript type\u003d\"text/javascript\" async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS_HTML-full\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003e给定四个整数 $$$n$$$、$$$c_0$$$、$$$c_1$$$ 和 $$$h$$$,以及一个长度为 $$$n$$$ 的二进制字符串 $$$s$$$。\u003c/p\u003e\u003cp\u003e二进制字符串是由字符 $$$0$$$ 和 $$$1$$$ 组成的字符串。\u003c/p\u003e\u003cp\u003e你可以改变字符串 $$$s$$$ 中的任何字符(改变后字符串仍应为二进制)。每次改变需要支付 $$$h$$$ 个硬币。\u003c/p\u003e\u003cp\u003e经过一些改变(可能为零次),你想要购买这个字符串。购买字符串需要购买其中的所有字符。购买字符 $$$0$$$ 需要支付 $$$c_0$$$ 个硬币,购买字符 $$$1$$$ 需要支付 $$$c_1$$$ 个硬币。\u003c/p\u003e\u003cp\u003e找到购买字符串所需的最少硬币数量。\u003c/p\u003e"}},{"title":"输入","value":{"format":"HTML","content":"\u003cp\u003e第一行包含一个整数 $$$t$$$($$$1 \\leq t \\leq 10$$$)— 测试用例的数量。接下来的 $$$2t$$$ 行包含测试用例的描述。\u003c/p\u003e\u003cp\u003e每个测试用例的描述的第一行包含四个整数 $$$n$$$、$$$c_{0}$$$、$$$c_{1}$$$、$$$h$$$($$$1 \\leq n, c_{0}, c_{1}, h \\leq 1000$$$)。\u003c/p\u003e\u003cp\u003e每个测试用例的描述的第二行包含长度为 $$$n$$$ 的二进制字符串 $$$s$$$。\u003c/p\u003e"}},{"title":"输出","value":{"format":"HTML","content":"\u003cp\u003e对于每个测试用例,输出一个整数 — 购买字符串所需的最少硬币数量。\u003c/p\u003e"}},{"title":"示例 1","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e6\n3 1 1 1\n100\n5 10 100 1\n01010\n5 10 1 1\n11111\n5 1 10 1\n11111\n12 2 1 10\n101110110101\n2 100 1 10\n00\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e3\n52\n5\n10\n16\n22\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e"}},{"title":"注意","value":{"format":"HTML","content":"\u003cp\u003e在第一个测试用例中,你可以购买所有字符并支付 $$$3$$$ 个硬币,因为字符 $$$0$$$ 和 $$$1$$$ 都需要 $$$1$$$ 个硬币。\u003c/p\u003e\u003cp\u003e在第二个测试用例中,你可以首先将字符串的第 $$$2$$$ 和第 $$$4$$$ 个符号从 $$$1$$$ 改变为 $$$0$$$,支付 $$$2$$$ 个硬币。你的字符串将变为 $$$00000$$$。然后,你可以购买字符串并支付 $$$5 \\cdot 10 \u003d 50$$$ 个硬币。总共支付的硬币数量将为 $$$2 + 50 \u003d 52$$$。\u003c/p\u003e"}}]}