Uva solution 12626 I ❤ Pizza

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,c1=0,c2=0,c3=0,c4=0,c5=0,c6=0,c=0,d;
    char ch[1000];
    cin>>n;
    cin.ignore();
    for(int j=1; j<=n; j++)
    {
        cin.getline(ch,1000);
        c=0,c1=0,c2=0,c3=0,c4=0,c5=0,c6=0,d=0;
        d=strlen(ch);
        for(int i=0; i<d; i++)
        {
            if(ch[i]=='M')
            {
                c1++;
            }
            else if(ch[i]=='A')
            {
                c2++;

            }
            else if(ch[i]=='R')
            {
                c3++;

            }
            else if(ch[i]=='G')
            {
                c4++;

            }
            else if(ch[i]=='I')
            {
                c5++;

            }
            else if(ch[i]=='T')
            {
                c6++;
            }
            if(c1>=1 && c2>=3 && c3>=2 && c4>=1 && c5>=1 && c6>=1)
            {
                c++;
                //cout<<c1<<" "<<c2<<" "<<c3<<" "<<c4<<" "<<c5<<" "<<c6<<endl;
                c1-=1,c2-=3,c3-=2,c4-=1,c5-=1,c6-=1;
                //cout<<c1<<" "<<c2<<" "<<c3<<" "<<c4<<" "<<c5<<" "<<c6<<endl;

            }
        }
        cout<<c<<endl;
    }
    return 0;
}

Comments

Popular posts from this blog

Codeforces Solution 230B T-primes

Uri Solution 2747 Output 1