[cpp]
/**本題是求最少移動次數,即比較第一個箱子中的相同顏色瓶子數量,不移動瓶子最多的那個,
*然後在剩余兩個箱子中繼續應用這個法則,最後得出總計6種移動順序,
*將6種情況的序列和最終箱子分別存放瓶子的顏色字符串定義為結構體並列舉出來,
*然後算出移動次數最少和顏色字符串的字典序最小的情況
*/
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
#define NUM 9
#define WAY 6
#define MAX 11
#define INF 0x7fffffff
int arr[MAX];
struct way{
int a, b, c;
string color;
}way[]={
{1,5,9,"BGC"},{1,8,6,"BCG"},{4,2,9,"GBC"},
{4,8,3,"CBG"},{7,2,6,"GCB"},{7,5,3,"CGB"}
};
int main(){
int maxv, count, sum;
string str;
while(~scanf("%d",&arr[1])){
maxv = -INF;
count = arr[1];
for(int i=2; i<=NUM; i++){
scanf("%d",&arr[i]);
count += arr[i];
}
for(int i=0; i<WAY; i++){
sum = arr[way[i].a]+arr[way[i].b]+arr[way[i].c];
if(maxv < sum){maxv = sum; str = way[i].color;}
else if(maxv==sum && str > way[i].color) str = way[i].color;
}
cout<<str<<' '<<count-maxv<<endl;
}
return 0;
}