码迷,mamicode.com
首页 > 其他好文 > 详细

Codeforces Round #493 (Div. 1)

时间:2018-07-10 11:24:52      阅读:95      评论:0      收藏:0      [点我收藏+]

标签:bsp   name   span   反转   def   return   ace   get   using   

A.

/*
发现每次反转或者消除都会减少一段0
当0只有一段时只能消除
这样判断一下就行


*/


#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<set>
#include<map>
#define M 300010
#define ll long long

using namespace std;
int read() {
    int nm = 0, f = 1;
    char c = getchar();
    for(; !isdigit(c); c = getchar()) if(c == -) f = -1;
    for(; isdigit(c); c = getchar()) nm = nm * 10 + c - 0;
    return nm * f;
}
ll n,x,y;
char s[M];
int main() {
    n = read(), x = read(), y = read();
    scanf("%s", s + 1);
    int len = strlen(s + 1);
    s[0] = ?;
    ll tot = 0;
    for(int i = 1; i <= len; i++) if(s[i] != s[i - 1] && s[i] == 0) tot++;
    if(tot == 0) return puts("0");
    cout << min(tot * y, tot * x - x + y);
    return 0;
}

 

Codeforces Round #493 (Div. 1)

标签:bsp   name   span   反转   def   return   ace   get   using   

原文地址:https://www.cnblogs.com/luoyibujue/p/9287318.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!