-
Notifications
You must be signed in to change notification settings - Fork 0
/
p12626.cpp
51 lines (50 loc) · 1.19 KB
/
p12626.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int main()
{
int a, m, r, g, i, t, n, j, k, count, pizza, c[6], x, check;
string s;
scanf("%d", &n);
getchar();
for(j=0; j<n; j++) {
getline(cin, s);
a = m = r = g = t = i = 0;
for(k=0; s[k]; k++) {
if(s[k]=='A') {
a++;
}else if(s[k]=='M') {
m++;
}else if(s[k]=='R') {
r++;
}else if(s[k]=='G') {
g++;
}else if(s[k]=='I') {
i++;
}else if(s[k]=='T') {
t++;
}
}
c[0] = m;
c[1] = a/3;
c[2] = r/2;
c[3] = g;
c[4] = i;
c[5] = t;
sort(c, c+6);
check = count = c[5];
x = pizza = 0;
a = a/3;
r = r/2;
while(check>0) {
check = count - x;
if(m>=check && a>=check && r>=check && g>=check && i>=check && t>=check) {
pizza = check;
break;
}
x++;
}
printf("%d\n", pizza);
}
}