CF997A.Convert to Ones

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You've got a string a1,a2,,ana_1, a_2, \dots, a_n , consisting of zeros and ones.

Let's call a sequence of consecutive elements ai,ai+1,,aja_i, a_{i + 1}, \ldots, a_j ( 1ijn1\leq i\leq j\leq 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» \to «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» \to «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?

输入格式

The first line of input contains integers nn , xx and yy ( 1n300000,0x,y1091 \leq n \leq 300\,000, 0 \leq x, y \leq 10^9 ) — 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.

输出格式

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.

输入输出样例

  • 输入#1

    5 1 10
    01000
    

    输出#1

    11
    
  • 输入#2

    5 10 1
    01000
    

    输出#2

    2
    
  • 输入#3

    7 2 3
    1111111
    

    输出#3

    0
    

说明/提示

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

Then the string was changed as follows:

«01000» \to «10000» \to «11111».

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

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

Then the string was changed as follows:

«01000» \to «11000» \to «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 .

首页