Codeforces Round #493 (Div. 1)

A.

/*
发现每次反转或者消除都会减少一段0
当0只有一段时只能消除
这样判断一下就行


*/


#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<set>
#include<map>
#define M 300010
#define ll long long

using namespace std;
int read() {
    int nm = 0, f = 1;
    char c = getchar();
    for(; !isdigit(c); c = getchar()) if(c == '-') f = -1;
    for(; isdigit(c); c = getchar()) nm = nm * 10 + c - '0';
    return nm * f;
}
ll n,x,y;
char s[M];
int main() {
    n = read(), x = read(), y = read();
    scanf("%s", s + 1);
    int len = strlen(s + 1);
    s[0] = '?';
    ll tot = 0;
    for(int i = 1; i <= len; i++) if(s[i] != s[i - 1] && s[i] == '0') tot++;
    if(tot == 0) return puts("0");
    cout << min(tot * y, tot * x - x + y);
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/luoyibujue/p/9287318.html