U E D R , A S I H C RSS

Ecological Bin Packing/김회영

~cpp 
//2.    
// 
//--->     . total .
//--->       
//  . max()함 통해  .  

#include<iostream>
using namespace std;

int container[9]; //    .
int total=0;      //    .
int ch_number;    //  .
char bgc[3]={'B','G','C'};
char save[4]={"NNN"}; //    

int max(int* array);
void main()
{
	cout<<"      "<<endl;
	for(int i=0 ; i<9 ; i++)
	{
		cin>>container[i];
		total+=container[i];
	}
	ch_number = total - max(container);
	cout<<endl;
	cout<<save<<"  "<<ch_number;
	cout<<endl;
}

int max(int* array) 
{

int temp=0;//   .
int max=0; //   .

for(int i=0 ; i<3 ; i++)
{
	for(int j=3 ; j<6 ; j++)	
	{
		if(j%3 == i)
			continue;
		else
		{
			temp+=array[i];
			temp+=array[j];
			temp+=array[12-(i+j)];
		}
		
		if(temp > max)
		{
			max=temp;
			save[0]=bgc[i];
			save[1]=bgc[(j%3)];
			save[2]=bgc[3-((j%3)+i)];
		}
		temp=0;
	}	
}

    return max;
}

태클

--
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:23:10
Processing time 0.0084 sec