// // 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; while(count < 3) { std::cin >> te[count]; sum += te[count]; count++; } std::cin >> aite; moji = (char *)malloc( strlen(aite.c_str()) + 1 ); std::sprintf(moji, "%s", aite.c_str()); count = 0; while (count < sum) { switch(moji[count]) { case 'G' : if(te[2] > 0) { point += 3; te[2]--; } else if(te[0] > 0) { point += 1; te[0]--; } else { te[1]--; } break; case 'C' : if(te[0] > 0) { point += 3; te[0]--; } else if(te[1] > 0) { point += 1; te[1]--; } else { te[2]--; } break; case 'P' : if(te[1] > 0) { point += 3; te[1]--; } else if(te[2] > 0) { point += 1; te[2]--; } else { te[0]--; } break; default: break; } count++; } std::cout << point << "\n"; return 0; }