Saturday 14 January 2017

Codecraft-17 and Codeforces Round #391 (Div. 1 + Div. 2, combined)/A. Gotta Catch Em' All!

Problem link: http://codeforces.com/contest/757/problem/A
Code:
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char ar[100009];
    long long i,B,u,l,b,a,s,r,ll,tamp;
    while(cin>>ar)
    {
        //Bulbasaur
        ll=strlen(ar);
        B=0;
        u=0;
        l=0;
        b=0;
        a=0;
        s=0;
        r=0;
        for(i=0; i<ll; i++)
        {
            if(ar[i]=='B')
                B++;
            else if(ar[i]=='u')
                u++;
            else if(ar[i]=='l')
                l++;
            else if(ar[i]=='b')
                b++;
            else if(ar[i]=='a')
                a++;
            else if(ar[i]=='s')
                s++;
            else if(ar[i]=='r')
                r++;
        }
        u/=2;
       // b/=2;
        a/=2;
        tamp=B;
        if(tamp>u)
            tamp=u;
        if(tamp>l)
            tamp=l;
        if(tamp>b)
            tamp=b;
        if(tamp>s)
            tamp=s;
        if(tamp>r)
            tamp=r;
        if(tamp>a)
            tamp=a;
        cout<<tamp<<endl;
    }
    return 0;
}

No comments:

Post a Comment