1.

import java.util.Scanner;

/**
* Angewandte Mathematik, SS11
* Problem: 102 Ecological Bin Packing
* Link: http://uva.onlinejudge.org/external/1/102.pdf
*
* @author Benedikt Z®nnchen
* @author Erik Wenzel
* @version 1.0, 03/25/2011
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 2.148
*/

public class Main
{

public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int[] brawn = new int[3];
int[] green = new int[3];
int[] clear = new int[3];
int brawnSum = 0;
int greenSum = 0;
int clearSum = 0;
String out = "";
int result = 0;
while(sc.hasNextLine() && sc.hasNextInt())
{
for(int i=1; i<=9; i++)
{
if(i%3 == 1)
{
brawn[i/3] = sc.nextInt();
brawnSum += brawn[i/3];
}
else if(i%3 == 2)
{
green[i/3] = sc.nextInt();
greenSum += green[i/3];
}
else // i%3==0
{
clear[(i-1)/3] = sc.nextInt();
clearSum += clear[(i-1)/3];
}
}

String tmp = "";
int tmpResult = 0;
for(int i=0; i<6; i++)
{
switch(i)
{
case 0:
tmp = "BCG ";
tmpResult = brawn[1]+brawn[2]+clear[0]+clear[2]+green[0]+green[1];
result = tmpResult;
out = tmp;
break;
case 2:
tmp = "BGC ";
tmpResult = brawn[1]+brawn[2]+green[0]+green[2]+clear[0]+clear[1];
break;
case 1:
tmp = "CBG ";
tmpResult = clear[1]+clear[2]+brawn[0]+brawn[2]+green[0]+green[1];
break;
case 3:
tmp = "CGB ";
tmpResult = clear[1]+clear[2]+green[0]+green[2]+brawn[0]+brawn[1];
break;
case 4:
tmp = "GBC ";
tmpResult = green[1]+green[2]+brawn[0]+brawn[2]+clear[0]+clear[1];
break;
case 5:
tmp = "GCB ";
tmpResult = green[1]+green[2]+clear[0]+clear[2]+brawn[0]+brawn[1];
break;
}
if(tmpResult < result)
{
result = tmpResult;
out = tmp;
}
}
System.out.println(out+result);
brawnSum = 0;
greenSum = 0;
clearSum = 0;
out = "";
result = 0;
}
sc.close();
}
}



-----------------------------

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);
}
}
}