日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Convert to Ones(CF-998C)

發布時間:2025/3/17 编程问答 16 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Convert to Ones(CF-998C) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Problem Description

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

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

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 x 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 y 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 n, x and y?(1?≤?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 a of length n, 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 0, if you do not need to perform any operations.

Examples

Input

5 1 10
01000

Output

11

Input

5 10 1
01000

Output

2

Input

7 2 3
1111111

Output

0

題意:給出一個長度為 n 的二進制串,有兩種操作:將某一段反序,花費為 x;將某一段取反,花費為 y,求將這個串全都變為1的最小花費

思路:假設 0 的段數為cnt,則:如果 x<=y,那么就進行 cnt-1 次操作 1 和一次操作 2 ;如果 x>y,那么就進行 cnt 次操作 2?

Source Program

#include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #include<string> #include<cstdlib> #include<queue> #include<set> #include<map> #include<stack> #include<ctime> #include<vector> #define INF 0x3f3f3f3f #define PI acos(-1.0) #define N 100001 #define MOD 1e9+7 #define E 1e-6 #define LL long long using namespace std; int main() {int n,x,y;string str;cin>>n>>x>>y;cin>>str;LL cnt=0;for(LL i=0;i<n;i++)if(str[i]=='0'&&str[i+1]=='1')cnt++;if(str[n-1]=='0')cnt++;LL minn;if(x<y)minn=x*(cnt-1)+y;elseminn=y*cnt;if(cnt==0)minn=0;cout<<minn<<endl;return 0; }

?

總結

以上是生活随笔為你收集整理的Convert to Ones(CF-998C)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: wwwxxx在线观看 | 少妇性色av | 成人性生交大免费看 | 精品人妻午夜一区二区三区四区 | 日韩成年人视频 | 欧美亚洲一区二区三区 | 日韩av中文在线观看 | 国产制服91一区二区三区制服 | 男生看的污网站 | 可以免费观看的av网站 | 鲁大师私人影院在线观看 | 亚洲第一狼人区 | 亚洲男男网站 | 蜜臀久久99精品久久久久宅男 | 精品一区二区在线看 | 国产蜜臀av一区二区 | 国产乡下妇女做爰 | 免费黄色一级 | 操www | 少妇高潮21p| 无码人妻精品一区二区蜜桃网站 | 亚洲综合不卡 | 片集网 | av在线看片| 探花国产精品一区二区 | 天天做天天爱天天爽 | 欧美视频日韩 | 日韩图片一区 | 成人乱人乱一区二区三区 | 无码精品一区二区三区AV | 亚洲二区一区 | 射射av | 国产精品jizz在线观看老狼 | 草久视频在线观看 | 天天看黄色片 | 欧美77777| 91大神久久 | av观看在线免费 | а√在线中文网新版地址在线 | 一区二区网站 | 少妇做爰免费视看片 | 亚洲精品v日韩精品 | 天堂网va | 日本黄色免费大片 | 久久午夜精品视频 | 日韩久久精品视频 | h狠狠躁死你h高h | 欧美黑人孕妇孕交 | 欧美做爰xxxⅹ性欧美大片 | 欧美日韩1区 | 中文字幕在线播出 | 曰批女人视频在线观看 | xvideos成人免费视频 | 激情午夜天 | 99热99| 手机看片国产1024 | 国产精品传媒麻豆hd | 久久精品视频一区二区三区 | 一区二区日韩在线观看 | 亚洲啪啪免费视频 | 国产理论片在线观看 | 中文字幕在线官网 | 日韩久久精品一区二区 | 凸凹人妻人人澡人人添 | 日韩午夜 | 日本天堂在线视频 | 香蕉视频黄色在线观看 | av视屏| 华丽的外出在线 | 亚洲欧美日韩综合在线 | 国产在线观看一区二区三区 | 久久超级碰碰 | 成人国产免费 | 国产精品国语 | 国产欧美久久久久 | 中文字幕在线免费视频 | 激情六月婷婷 | 成人一区二区三区仙踪林 | 色视频在线观看 | 天天上天天干 | 日韩精品一区二区三区中文在线 | 最近更新中文字幕 | 国产污污视频 | 国产黄a三级三级三级看三级男男 | 欧美人一级淫片a免费播放 西方av在线 | 91丨九色丨国产在线 | 黄色日皮视频 | 99国产精品视频免费观看一公开 | 亚洲国产精品99久久久久久久久 | 中国女人毛茸茸 | 日韩少妇裸体做爰视频 | 免费久久精品 | 国产后入清纯学生妹 | 欧美大黄视频 | 免费在线视频一区 | 在线播放毛片 | 亚洲男人天堂av | 一区不卡在线观看 | 亚洲风情第一页 |