// ConsoleApplication1.cpp : コンソール アプリケーションのエントリ ポイントを定義します。 // #include #include #include using namespace std; void f(string s, int *S) { S[0] = 0; S[1] = 0; S[2] = 0; for (int i = 0; i < s.length(); i++) { if (s[i] == 'G') { S[0]++; } else if (s[i] == 'C') { S[1]++; } else if(s[i]=='P'){ S[2]++; } } } int main() { int g,c,p; cin >> g >> c >> p; string s; int *S = new int[3]; cin >> s; f(s, S); int N = 0; int x, y, z; x = min(g, S[1]); y = min(c, S[2]); z = min(p, S[0]); g -= x; S[1] -= x; c -= y; S[2] -= y; p -= z; S[0] -= z; N += 3 * (x + y + z); int X,Y,Z; X = min(g, S[0]); Y = min(c, S[1]); Z = min(p, S[2]); N += 1 * (X+Y+Z); cout << N; return 0; }