/997/problem/A Convert to Ones

A. Convert to Ones

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

You've got a string a1,a2,…,ana1,a2,…,an, consisting of zeros and ones.

Let's call a sequence of consecutive elements ai,ai+1,…,ajai,ai + 1,…, aj (1≤i≤j≤n1≤ i≤ j≤ n) a substring of string aa.

You can apply the following operations any number of times:

  • Choose some substring of string aa (for example, you can choose entire string) and reverse it, paying xx coins for it (for example, «0101101» →→ «0111001»);
  • Choose some substring of string aa (for example, you can choose entire string or just one symbol) and replace each symbol to the opposite one (zeros are replaced by ones, and ones — by zeros), paying yy coins for it (for example, «0101101» →→ «0110001»).

You can apply these operations in any order. It is allowed to apply the operations multiple times to the same substring.

What is the minimum number of coins you need to spend to get a string consisting only of ones?

Input

The first line of input contains integers nn, xx and yy (1≤n≤300000,0≤x,y≤1091 ≤ n ≤ 300000,0≤x,y≤109) — length of the string, cost of the first operation (substring reverse) and cost of the second operation (inverting all elements of substring).

The second line contains the string aa of length nn, consisting of zeros and ones.

Output

Print a single integer — the minimum total cost of operations you need to spend to get a string consisting only of ones. Print 00, if you do not need to perform any operations.

Examples

input

Copy

5 1 10
01000

output

Copy

11

input

Copy

5 10 1
01000

output

Copy

2

input

Copy

7 2 3
1111111

output

Copy

0

Note

In the first sample, at first you need to reverse substring [1…2][1…2], and then you need to invert substring [2…5][2…5].

Then the string was changed as follows:

«01000» →→ «10000» →→ «11111».

The total cost of operations is 1+10=111+10=11.

In the second sample, at first you need to invert substring [1…1][1…1], and then you need to invert substring [3…5][3…5].

Then the string was changed as follows:

«01000» →→ «11000» →→ «11111».

The overall cost is 1+1=21+1=2.

In the third example, string already consists only of ones, so the answer is 00.

#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n;
    long long a,b;
    bool x[300005];
    cin>>n>>a>>b;
    for(int i=0; i<n; i++)
       {
           char w;
           cin>>w;
           x[i]=w-48;
      //  cout<<x[i]<<endl;
       }
    long long num=x[0]==0?1:0;//cout<<num<<endl;
    for(int i=1; i<n; i++)
    {
        if(x[i-1]==1&&x[i]==0)
        {
            num++;

        }
    }

    long long ans=num*b;
    for(long long i=0; i<num; i++)
    {
        ans=min(ans,(num-i)*b+i*a);
    }
    cout<<ans;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值