1.

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

/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, SS11
* Problem: 102 Ecological Bin Packing
* Link: http://uva.onlinejudge.org/external/1/102.pdf
*
* @author Weigl Joseph
* @author Müller Thomas
* @version 1.0, 04/06/2011
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 1.028
*/


public class Main {

static int[] colors = new int[3];

public static int movements(int[][] row, int[] input){
int moves = 0;
int best = Integer.MAX_VALUE;
int[] bestRow = new int[3];
for(int e = 0; e < 6; e++){
moves = 0;
for(int i = 0; i < 9; i++){
if(((i)%3)+1 != row[e][(i)/3])
moves += input[i];
}
if(moves < best){
bestRow = row[e];
best = moves;
}
}
for(int i : bestRow){
if(i == 1)
System.out.print("B");
else if(i == 2)
System.out.print("G");
else if(i == 3)
System.out.print("C");
}
System.out.print(" ");
System.out.println(best);
return best;
}


public static void main(String... args) throws IOException{

BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer token;

int[][] row = {{1,3,2},{1,2,3},{3,1,2},{3,2,1},{2,1,3},{2,3,1}};
int[] input = new int[9];

// token = new StringTokenizer(reader.readLine());

while(reader.ready()){
token = new StringTokenizer(reader.readLine());
int min = 0;

for(int i = 0; i < input.length; i++)
input[i] = Integer.parseInt(token.nextToken());

min = movements(row, input);

}
}


}
-------------------------------------------------------------------------------------------------

1.

/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, SS10
* Problem: 102 Ecological Bin Packing
* Link: http://uva.onlinejudge.org/external/1/102.html
*
* @author Barny Porcio
* @version 1.0, 04/10/2010
*
* Method : -
* Status : Accepted
* Runtime: 1.312
*/
import java.util.Scanner;


public class ecologicalbinpacking102 {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
String[] solu = new String[]{"BCG","BGC","CBG","CGB","GBC","GCB"};
//
while (sc.hasNext()){
int[][] box = new int[3][3];
for (int i = 0;i <9;++i)
box[i/3][i%3] = sc.nextInt();
//0 = brown 1= green 2 = clean
int min ;
//Array wird befüllt, bevorzugt mit 0 2 1 Prioritaet
int[] lala = new int[6];
lala[1] = box[0][1]+box[0][2]+box[1][0]+box[1][2]+box[2][0]+box[2][1]; // 0 1 2 2
min = lala[1];
lala[0] = box[0][1]+box[0][2]+box[1][0]+box[1][1]+box[2][0]+box[2][2]; // 0 2 1 1
if (lala[0] < min )
min = lala[0];
lala[4] = box[0][0]+box[0][2]+box[1][1]+box[1][2]+box[2][0]+box[2][1]; // 1 0 2 5
if (lala[4] < min )
min = lala[4];
lala[5] = box[0][0]+box[0][2]+box[1][0]+box[1][1]+box[2][1]+box[2][2]; // 1 2 0 6
if (lala[5] < min )
min = lala[5];
lala[2] = box[0][0]+box[0][1]+box[1][1]+box[1][2]+box[2][0]+box[2][2]; // 2 0 1 3
if (lala[2] < min )
min = lala[2];
lala[3] = box[0][0]+box[0][1]+box[1][0]+box[1][2]+box[2][1]+box[2][2]; // 2 1 0 4
if (lala[3] < min )
min = lala[3];
int i = 0;
while (min != lala[i])
i++;
System.out.println(solu[i]+" "+min);
}
}
}