1 #include <iostream> 2 #include <cstdio> 3 #include <string> 4 #include <algorithm> 5 #include <map> 6 using namespace std; 7 8 int main() 9 { 10 int N, number; 11 string str; 12 map<char, int> pizzas; 13 cin >> N; 14 while(N--) 15 { 16 //getline(cin, str); //have something trouble? 17 pizzas['A'] = 0; // 3 18 pizzas['R'] = 0; // 2 19 pizzas['M'] = 0; // 1 20 pizzas['G'] = 0; // 1 21 pizzas['I'] = 0; // 1 22 pizzas['T'] = 0; // 1 23 cin >> str; 24 for(map<char, int>::iterator imap=pizzas.begin(); imap!=pizzas.end(); ++imap) 25 { 26 for(string::iterator istr=str.begin(); istr!=str.end(); ++istr) 27 { 28 if(imap->first == *istr) 29 imap->second ++; 30 } 31 } 32 33 number = 200; 34 number = min(number, pizzas['A']/3); 35 number = min(number, pizzas['R']/2); 36 number = min(number, pizzas['M']/1); 37 number = min(number, pizzas['G']/1); 38 number = min(number, pizzas['I']/1); 39 number = min(number, pizzas['T']/1); 40 41 cout << number << endl; 42 } 43 return 0; 44 }