每次肯定是对一段连续的 $0$ 或者 $1$ 进行操作.

对于一段连续的 $0$,要么直接变为 $1$,要么与右面的连续的 $1$ 交换.

如果与右面的 $1$ 翻转更加合适,那么就肯定会一直翻转,并在不能交换的时候变为 0.

否则,就会一直将子序列变为 $0$.

即 $ans=min(num[0]\times y,(num[0]-1)\times x+y)$

#include <cstdio>
#include <algorithm>
#define ll long long
#define setIO(s) freopen(s".in", "r" , stdin)
using namespace std;
ll x, y;
char str[300005];
int n ,a[2], i, pre = -1;
int main()
{
// setIO("input");
scanf("%d%lld%lld%s", &n, &x, &y, str + 1);
for(i = 1; i <= n ; ++ i)
{
int cur = str[i] - '0';
scanf("%d", &cur);
if(cur != pre) ++ a[cur], pre = cur;
}
printf("%lld\n", max(1ll*0, min(1ll * a[0] * y, 1ll * (a[0] - 1) * x + y)));
return 0;
}

  

Codeforces Round #493 (Div. 2) C. Convert to Ones 乱搞_构造_好题的更多相关文章

  1. Codeforces Round #493 (Div 2) (A~E)

    目录 Codeforces 998 A.Balloons B.Cutting C.Convert to Ones D.Roman Digits E.Sky Full of Stars(容斥 计数) C ...

  2. Codeforces Round #493 (Div. 2)

    C - Convert to Ones 给你一个01串 x是反转任意子串的代价 y是将子串全部取相反的代价 问全部变成1的最小代价 两种可能 一种把1全部放到一边 然后把剩下的0变成1  要么把所有的 ...

  3. Cutting Codeforces Round #493 (Div. 2)

    Cutting There are a lot of things which could be cut — trees, paper, “the rope”. In this problem you ...

  4. Codeforces Round #493 (Div. 1)

    A. /* 发现每次反转或者消除都会减少一段0 当0只有一段时只能消除 这样判断一下就行 */ #include<cstdio> #include<algorithm> #in ...

  5. Codeforces Round #493 (Div. 2)D. Roman Digits 第一道打表找规律题目

    D. Roman Digits time limit per test 1 second memory limit per test 256 megabytes input standard inpu ...

  6. 【Codeforces Round #493 (Div. 2) B】Cutting

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 显然只有在前i个位置奇数偶数出现次数都相同的地方才能切. (且不管前面怎么切,这里都能切的. 那么就相当于有n个物品,每个物品的代价 ...

  7. Codeforces Round #493 (Div. 2) A. Balloons 贪心水题

    由于是输出任意一组解,可以将价值从小到大进行排序,第一个人只选第一个,第二个人选其余的.再比较一下第一个人选的元素和第二个人所选元素和是否相等即可.由于已将所有元素价值从小到大排过序,这样可以保证在有 ...

  8. Codeforces Round #493 (Div. 1) B. Roman Digits 打表找规律

    题意: 我们在研究罗马数字.罗马数字只有4个字符,I,V,X,L分别代表1,5,10,100.一个罗马数字的值为该数字包含的字符代表数字的和,而与字符的顺序无关.例如XXXV=35,IXI=12. 现 ...

  9. Codeforces Round #493 (Div. 2) B. Cutting 前缀和优化_动归水题

    不解释,题目过水 Code: #include<cstdio> #include<cmath> #include<algorithm> using namespac ...

随机推荐

  1. php 的多进程

    php的多进程处理依赖于pcntl扩展,通过pcntl_fork创建子进程来进行并行处理 例子1: <?php $pid = pcntl_fork(); if($pid == -1) { //错 ...

  2. sql修改字段值

    update dfw_USER_ACCOUNTS set USER_INTEGRAL="20" where USER_INTEGRAL="17"

  3. 4.1、Ansible模块

    ansible-doc -l    列出所有模块 ansible-doc 模块名    查看模块的help说明 ansible-doc -s  module_name:获取指定模块的使用信息 ***文 ...

  4. java实现根据起点终点和日期查询去哪儿网的火车车次和火车站点信息

    本文章为原创文章,转载请注明,欢迎评论和改正. 一,分析 之前所用的直接通过HTML中的元素值来爬取一些网页上的数据,但是一些比较敏感的数据,很多正规网站都是通过json数据存储,这些数据通过HTML ...

  5. Python 不同列表时间测试

    import timeit import threading def test1(): l = [] for i in range(1000): l = l + [i] def test2(): l ...

  6. Mysql提升大数据导入速度的绝妙方法

    一.对于Myisam类型的表,可以通过以下方式快速的导入大量的数据.      ALTER TABLE tblname DISABLE KEYS;     loading the data     A ...

  7. hdu 2435 dinic算法模板+最小割性质

    #include<stdio.h> #include<queue> #include<string.h> using namespace std; #define ...

  8. C#中的Attribute定义及用法

    1.Attribute定义 公共语言运行时允许添加类似关键字的描述声明,叫做attributes, 它对程序中的元素进行标注,如类型.字段.方法和属性等.Attributes和Microsoft .N ...

  9. css3 transform 旋转div

    css3 transform 旋转div 学习了:http://www.w3school.com.cn/cssref/pr_transform.asp

  10. java 递归实现删除或查询指定目录下的全部文件

    /** * 递归列举盘符下的全部文件的名称,如E:\HeartIsland * * @author HeartIsland * */ public class FileListDemo { /** * ...