1.

/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, WS09
* Problem: 102 Ecological Bin Packing
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=3&page=show_problem&problem=38
*
* @author Kratzer Kevin
* @version 1.0, 10/07/2009
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 0.968
*/




import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;



public class Main102 {

protected final BufferedReader input;
public static int brown = 0;
public static int green = 1;
public static int clear = 2;
public Main102() {
input = new BufferedReader(new InputStreamReader(System.in));
}

void process() throws IOException {
String line = input.readLine();
int[] bottles = new int[9];
while(line != null) {
String[] lineSplit = line.split(" ");
for(int i = 0; i < lineSplit.length; i++) {
bottles[i] = Integer.parseInt(lineSplit[i]);
}
Result best = new Result(Integer.MAX_VALUE);
for(int i=0; i<3;i++) {
int curMoves = move(i,brown,bottles);
for(int j=0;j<3;j++) {
if(j == i) {
continue;
}
for(int k=0;k<3;k++) {
if(k == i || k == j) {
continue;
}
int curMoveRes = curMoves + move(j,green,bottles) + move(k,clear,bottles);
if(best.getMoves() > curMoveRes || ((best.getMoves() == curMoveRes) && (i < best.getBrownPos())) || ((best.getMoves() == curMoveRes) && (i == best.getBrownPos()) && k < best.getClearPos())) {
best.setMoves(curMoveRes);
best.setBrownPos(i);
best.setGreenPos(j);
best.setClearPos(k);
}
}
}
}
best.printResult();
line = input.readLine();
}

}


private int move(int pos, int bottleType, int[] input) {
//System.out.println(pos + " " + bottleType + " " + (input[0+bottleType] + input[3+bottleType] + input[6+bottleType] - input[pos+bottleType]));
return input[0+bottleType] + input[3+bottleType] + input[6+bottleType] - input[pos*3+bottleType];

}

public static void main(String... args) throws Exception {
new Main102().process();
}

public static class Result {
public int brownPos;
public int greenPos;
public int clearPos;
public int moves;
public Result(int moves) {
this.moves = moves;
}
public int getBrownPos() {
return brownPos;
}
public void setBrownPos(int brownPos) {
this.brownPos = brownPos;
}
public int getGreenPos() {
return greenPos;
}
public void setGreenPos(int greenPos) {
this.greenPos = greenPos;
}
public int getClearPos() {
return clearPos;
}
public void setClearPos(int clearPos) {
this.clearPos = clearPos;
}
public int getMoves() {
return moves;
}
public void setMoves(int moves) {
this.moves = moves;
}

public void printResult() {
char[] combination = new char[3];
combination[brownPos] = 'B';
combination[greenPos] = 'G';
combination[clearPos] = 'C';
//System.out.println(brownPos + " " + greenPos + " " + clearPos + " ");
System.out.println(new String(combination) + " " + moves);
}

}
}


2.

/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, WS09
* Problem: 102 Ecological Bin Packing
* Link: http://uva.onlinejudge.org/external/1/102.html
*
* @author Christoph Hausmann
* @version 0.1, 10/7/2009
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 1.116
*/

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class EcologicalBinPacking_102 {
public static enum Color {
B, G, C;
}

public static class Bin {
Color color;

int brown = 0;
int green = 0;
int clear = 0;
}

public static void main(String... args) throws IOException {
final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

String curLine = br.readLine();

while(curLine != null) {
final String[] curStrings = curLine.split(" ");

final Bin bin1 = new Bin();
final Bin bin2 = new Bin();
final Bin bin3 = new Bin();

bin1.brown = Integer.parseInt(curStrings[0]);
bin1.green = Integer.parseInt(curStrings[1]);
bin1.clear = Integer.parseInt(curStrings[2]);

bin2.brown = Integer.parseInt(curStrings[3]);
bin2.green = Integer.parseInt(curStrings[4]);
bin2.clear = Integer.parseInt(curStrings[5]);

bin3.brown = Integer.parseInt(curStrings[6]);
bin3.green = Integer.parseInt(curStrings[7]);
bin3.clear = Integer.parseInt(curStrings[8]);

int bestMoves = Integer.MAX_VALUE;
String output = "";

for(final Color firstColor : Color.values()) {
bin1.color = firstColor;
for(final Color secondColor : Color.values()) {
if(secondColor == firstColor)
continue;

bin2.color = secondColor;
for(final Color thirdColor : Color.values()) {
if(thirdColor == firstColor || thirdColor == secondColor)
continue;

bin3.color = thirdColor;


int moves = tryConfig(bin1,bin2,bin3);

final String curOutput = bin1.color.name() + bin2.color.name() + bin3.color.name() + " " + moves;

if(moves < bestMoves || (moves == bestMoves && output.compareTo(curOutput) > 0)) {
bestMoves = moves;
output = curOutput;
}
}
}
}

System.out.println(output);

curLine = br.readLine();
}
}

private static int tryConfig(Bin bin1, Bin bin2, Bin bin3) {
int moves = 0;

final Bin brown = findBin(Color.B,bin1,bin2,bin3);
final Bin green = findBin(Color.G,bin1,bin2,bin3);
final Bin clear = findBin(Color.C,bin1,bin2,bin3);


moves += green.brown + clear.brown;

moves += brown.green + clear.green;

moves += brown.clear + green.clear;

return moves;
}

private static Bin findBin(Color g, Bin... bins) {
for(final Bin curBin : bins) {
if(curBin.color == g)
return curBin;
}

return null;
}
}

3.

/**
* FWP, Ausgewhlte Probleme aus dem ACM Programming Contest, WS09
* Problem: 102 - Ecological Bin Packing
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=3&page=show_problem&problem=38
*
* @author Stefan Gohlke
* @version 1.0, 12/09/2009
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 1.088
*/

package ecologicalbinpacking_acc;

import java.util.Scanner;

public class Main {

public static void main (String[] args)
{
ecobin();
}

public static void ecobin()
{
Scanner scanner = new Scanner(System.in);
int binOneBrown;
int binOneGreen;
int binOneClear;
int binTwoBrown;
int binTwoGreen;
int binTwoClear;
int binThreeBrown;
int binThreeGreen;
int binThreeClear;

while(scanner.hasNextInt())
{

binOneBrown = scanner.nextInt();
binOneGreen = scanner.nextInt();
binOneClear = scanner.nextInt();

binTwoBrown = scanner.nextInt();
binTwoGreen = scanner.nextInt();
binTwoClear = scanner.nextInt();

binThreeBrown = scanner.nextInt();
binThreeGreen = scanner.nextInt();
binThreeClear = scanner.nextInt();

int minimum;
int zwischen;
String minimumString;


//Fall1: BCG
minimum = (binTwoBrown + binThreeBrown) + (binOneClear + binThreeClear) + (binOneGreen + binTwoGreen);
minimumString = "BCG";

//Fall2: BGC
zwischen = (binTwoBrown + binThreeBrown) + (binOneGreen + binThreeGreen) + (binOneClear + binTwoClear);

if (zwischen < minimum) {
minimum = zwischen;
minimumString = "BGC";
}

//Fall3: CBG
zwischen = (binTwoClear + binThreeClear) + (binOneBrown + binThreeBrown) + (binOneGreen + binTwoGreen);
if (zwischen < minimum) {
minimum = zwischen;
minimumString = "CBG";
}

//Fall4: CGB
zwischen = (binTwoClear + binThreeClear) + (binOneGreen + binThreeGreen) + (binOneBrown + binTwoBrown);
if (zwischen < minimum) {
minimum = zwischen;
minimumString = "CGB";
}


//Fall5: GBC
zwischen = (binTwoGreen + binThreeGreen) + (binOneBrown + binThreeBrown) + (binOneClear + binTwoClear);
if (zwischen < minimum) {
minimum = zwischen;
minimumString = "GBC";
}

//Fall6: GCB
zwischen = (binTwoGreen + binThreeGreen) + (binOneClear + binThreeClear) + (binOneBrown + binTwoBrown);
if (zwischen < minimum) {
minimum = zwischen;
minimumString = "GCB";
}

System.out.println(minimumString + " " + minimum);

}
}
}