https://codeforces.com/problemset/problem/997/A
输入 n(1≤n≤3e5) x(0≤x≤1e9) y(0≤y≤1e9) 和长为 n 的 01 字符串 s。
你可以执行任意次操作,每次选择其中一种操作执行。
1. 花费 x,reverse s 的一个子串,例如 1110 -> 0111。
2. 花费 y,flip s 的一个子串,例如 1110 -> 0001。
目标:使 s 中只有 1。
输出最少花费。
输入
5 1 10
01000
输出
11
输入
5 10 1
01000
输出
2
输入
7 2 3
1111111
输出
0
#include <bits/stdc++.h>
using namespace std;
int main ()
{
string s;
int n, x, y;
cin >> n >> x >> y >> s;
int cnt = 0;
for(int i = 0; i < n; i ++)
{
if(s[i] == '0') cnt ++;
int j = i;
while(j < n && s[j] == '0') j ++;
i = j;
}
long long t = min( 1ll * (cnt - 1) * x + y, 1ll * cnt * y);
cout << max(1ll * 0, t);
return 0;
}