Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <map>
- #include <algorithm>
- using namespace std;
- int main() {
- int n;
- cin>>n;
- cin.ignore();
- while (n--){
- string stringLine;
- map<char, int> charMap;
- cin>>stringLine;
- int max = 0;
- for (int i = 0; i <stringLine.size() ; ++i) {
- char t = stringLine[i];
- if (t == 'M' || t=='A' || t=='R' || t=='G' || t=='I' || t=='T'){
- charMap[t] +=1;
- if ( charMap[t] > max )
- max = charMap[t];
- }
- }
- int count =0;
- if (charMap['A'] > 2 && charMap['R'] > 1 && charMap['M'] > 0
- && charMap['G'] > 0 && charMap['T'] > 0 && charMap['I'] > 0) {
- for (int i = 0; i < max; ++i) {
- bool flag = true;
- for (auto i = charMap.begin(); i != charMap.end(); ++i) {
- if (i->second != 0)
- charMap[i->first] -= 1;
- else
- flag = false;
- }
- if (flag == true)
- count += 1;
- }
- }
- cout<<count<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement