305246: CF997A. Convert to Ones
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Convert to Ones
题意翻译
给你一个长度为 $n$ 的01串( $n \leq 3*10^5$ ),你有两种操作: 1.将一个子串翻转,花费 $X$ 2.将一个子串中的0变成1,1变成0,花费 $Y$ 求你将这个01串变成全是1的串的最少花费。 感谢@litble 提供翻译题目描述
You've got a string $ a_1, a_2, \dots, a_n $ , consisting of zeros and ones. Let's call a sequence of consecutive elements $ a_i, a_{i + 1}, \ldots, a_j $ ( $ 1\leq i\leq j\leq n $ ) a substring of string $ a $ . You can apply the following operations any number of times: - Choose some substring of string $ a $ (for example, you can choose entire string) and reverse it, paying $ x $ coins for it (for example, «0101101» $ \to $ «0111001»); - Choose some substring of string $ a $ (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 $ y $ 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 $ n $ , $ x $ and $ y $ ( $ 1 \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 $ a $ of length $ n $ , 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 $ 0 $ , 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