Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Author: LinChuWen
- Date: 2014/10/12
- UVa Online Judge Problem #102 - Ecological Bin Packing
- Description: http://uva.onlinejudge.org/external/1/102.pdf
- */
- #include <stdio.h>
- #include <stdlib.h>
- int main(){
- int b1,g1,c1,b2,g2,c2,b3,g3,c3;
- long long int b1_sum,g1_sum,c1_sum,b2_sum,g2_sum,c2_sum,b3_sum,g3_sum,c3_sum;
- long long int total[6],min;
- int cnt,index;
- while(scanf("%d %d %d %d %d %d %d %d %d",&b1,&g1,&c1,&b2,&g2,&c2,&b3,&g3,&c3)==9){
- 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:
- printf("BCG %lld\n",total[0]);
- break;
- case 1:
- printf("BGC %lld\n",total[1]);
- break;
- case 2:
- printf("CBG %lld\n",total[2]);
- break;
- case 3:
- printf("CGB %lld\n",total[3]);
- break;
- case 4:
- printf("GBC %lld\n",total[4]);
- break;
- case 5:
- printf("GCB %lld\n",total[5]);
- break;
- } /* switch end */
- } /* big while end */
- system("PAUSE");
- return 0;
- } /* main end */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement