Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Date: 2014.10.25
- * @author LinChuWen
- * UVa Online Judge Problem #102 - Ecological Bin Packing
- * Description: http://uva.onlinejudge.org/external/1/102.pdf
- */
- import java.util.Scanner;
- public class Uva_102 {
- public static void main (String[] args){
- Scanner input = new Scanner(System.in);
- long b1_sum,g1_sum,c1_sum,b2_sum,g2_sum,c2_sum,b3_sum,g3_sum,c3_sum,min;
- long[] total =new long[6];
- int cnt,index;
- while(input.hasNext()){
- int b1 = input.nextInt();
- int g1 = input.nextInt();
- int c1 = input.nextInt();
- int b2 = input.nextInt();
- int g2 = input.nextInt();
- int c2 = input.nextInt();
- int b3 = input.nextInt();
- int g3 = input.nextInt();
- int c3 = input.nextInt();
- b1_sum=b2+b3;g1_sum=g2+g3;c1_sum=c2+c3;
- b2_sum=b1+b3;g2_sum=g1+g3;c2_sum=c1+c3;
- b3_sum=b1+b2;g3_sum=g1+g2;c3_sum=c1+c2;
- total[0]=b1_sum+c2_sum+g3_sum;
- total[1]=b1_sum+g2_sum+c3_sum;
- total[2]=c1_sum+b2_sum+g3_sum;
- total[3]=c1_sum+g2_sum+b3_sum;
- total[4]=g1_sum+b2_sum+c3_sum;
- total[5]=g1_sum+c2_sum+b3_sum;
- index = 0;
- min = total[0];
- for(cnt=1;cnt<6;cnt++){
- if(total[cnt]<min){
- min=total[cnt];
- index=cnt;
- } //if end
- } //for end
- switch(index){
- case 0:
- System.out.println("BCG " + total[0]);
- break;
- case 1:
- System.out.println("BGC " + total[1]);
- break;
- case 2:
- System.out.println("CBG " + total[2]);
- break;
- case 3:
- System.out.println("CGB " + total[3]);
- break;
- case 4:
- System.out.println("GBC " + total[4]);
- break;
- case 5:
- System.out.println("GCB " + total[5]);
- break;
- } //switch end
- } //while end
- input.close();
- } //main end
- } //class end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement