Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <algorithm>
- using namespace std;
- int main()
- {
- // ifstream cin("input.txt");
- long long n,x,y;
- cin>>n>>x>>y;
- string p;
- cin>>p;
- string s="";
- for(long long i=0;i<n;i++)
- {
- s+=p[i];
- long long j=i;
- while(j<n && p[j]==p[i])
- {
- j++;
- }
- i=j-1;
- }
- n=s.size();
- if(n == 1 and s[0] == '1') {
- return 0 * printf("0");
- }
- long long ans=0;
- if(y<=x)
- {
- for(long long i=0;i<n;i++)
- {
- if(s[i]=='0')
- {
- ans+=y;
- }
- }
- }
- else if(x<y)
- {
- if(s.size()>=1)
- {
- ans+=y;
- for(long long i=1;i<s.size()-1;i++)
- {
- if(s[i]=='1')
- {
- ans+=x;
- }
- }
- }
- }
- cout<<ans<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement