Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- int t;
- string a,b;
- scanf("%d",&t);
- getline(cin,b);
- while(t-- && getline(cin,a))
- {
- int A=0,R=0,M=0,G=0,I=0,T=0,pizza=0;
- int len=a.size();
- for(int i=0; i<len; i++)
- {
- if(a[i]=='A')
- {
- A++;
- }
- else if(a[i]=='R')
- {
- R++;
- }
- else if(a[i]=='M')
- {
- M++;
- }
- else if(a[i]=='G')
- {
- G++;
- }
- else if(a[i]=='I')
- {
- I++;
- }
- else if(a[i]=='T')
- {
- T++;
- }
- }
- while(len--)
- {
- if(A>=3 && R>=2 && M>=1 && G>=1 && I>=1 && T>=1)
- {
- pizza++;
- A=A-3;
- M=M-1;
- R=R-2;
- G=G-1;
- I=I-1;
- T=T-1;
- }
- else
- {
- break;
- }
- }
- printf("%d\n",pizza);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement