~cpp
#include<iostream>
#include<string>
using namespace std;
#define NumberOfSlots 9
#define NumberOfCases 6
#define NumberOfResultInformations 2
int* input();
int* setNotMove(int *aSlots);
int* minimumMove(int *aSlots);
void output(int *aInformation);
bool isCorrectInput;
void main()
{
isCorrectInput = true;
output(minimumMove(input()));
}
int* input()
{
int* slots = new int[NumberOfSlots + 1];
int totalBottle = 0;
for(int i = 0; i < NumberOfSlots; i++)
{
if(!(cin >> slots[i])){
isCorrectInput = false;
}
totalBottle += slots[i];
}
char temp;
cin.get(temp);
if(temp != '\n')
isCorrectInput = false;
slots[9] = totalBottle;
return slots;
}
int* setNotMove(int *aSlots)
{
int* noMove = new int[NumberOfCases];
noMove[0] = aSlots[0] + aSlots[4] + aSlots[8];
noMove[1] = aSlots[0] + aSlots[5] + aSlots[7];
noMove[2] = aSlots[1] + aSlots[3] + aSlots[8];
noMove[3] = aSlots[1] + aSlots[5] + aSlots[6];
noMove[4] = aSlots[2] + aSlots[3] + aSlots[7];
noMove[5] = aSlots[2] + aSlots[4] + aSlots[6];
return noMove;
}
int* minimumMove(int *aSlots)
{
if(!isCorrectInput){
delete aSlots;
int *temp = new int;
return temp;
}
int MAX = 0;
int minimumCase;
int* pNoMove = setNotMove(aSlots);
for(int i = 0; i < NumberOfCases; i++)
{
if(pNoMove[i] > MAX)
{
MAX = pNoMove[i];
minimumCase = i;
}
}
aSlots[9] -= MAX;
int *resultInformation = new int[NumberOfResultInformations];
resultInformation[0] = minimumCase;
resultInformation[1] = aSlots[9];
delete aSlots;
delete pNoMove;
return resultInformation;
}
void output(int *aInformation)
{
if(isCorrectInput)
{
string colorsCombination[] = {"BGC", "BCG", "GBC", "GCB", "CBG", "CGB"};
cout << colorsCombination[aInformation[0]] << aInformation[1] << endl;
}
else
{
cout << "잘못된 입력으로 프로그램을 종료합니다.\n";
}
delete aInformation;
}