// // main.cpp // Q256 // // Created by AkihiroKOBAYASHI on 7/10/15. // Copyright (c) 2015 Akhr5884. All rights reserved. // #include #include int main(int argc, const char * argv[]) { int te[3]; int count = 0; int sum = 0; int point = 0; std::string aite; char *moji; int *already; while(count < 3) { std::cin >> te[count]; sum += te[count]; count++; } std::cin >> aite; moji = (char *)malloc( strlen(aite.c_str()) + 1 ); already = (int*)malloc( strlen(aite.c_str()) + 1 ); std::sprintf(moji, "%s", aite.c_str()); // win count = 0; while (count < sum) { already[count] = 0; switch(aite[count]) { case 'G': if(te[2] > 0) { te[2]--; point += 3; already[count] = 1; } break; case 'C': if(te[0] > 0) { te[0]--; point += 3; already[count] = 1; } break; case 'P': if(te[1] > 0) { te[1]--; point += 3; already[count] = 1; } break; } count++; } // draw count = 0; while (count < sum) { if(already[count] != 1) { switch(aite[count]) { case 'G': if(te[0] > 0) { te[0]--; point += 1; already[count] = 1; } break; case 'C': if(te[1] > 0) { te[1]--; point += 1; already[count] = 1; } break; case 'P': if(te[2] > 0) { te[2]--; point += 1; already[count] = 1; } break; } } count++; } std::cout << point << "\n"; return 0; }