-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathp102.cpp
40 lines (33 loc) · 997 Bytes
/
p102.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include<iostream>
using namespace std;
int main()
{
int b1,g1,c1,b2,g2,c2,b3,g3,c3,i,a[6],min;
while(cin>>b1>>g1>>c1>>b2>>g2>>c2>>b3>>g3>>c3){
a[0]=b2+b3+c1+c3+g1+g2;
a[1]=b2+b3+c1+c2+g1+g3;
a[2]=b1+b3+c2+c3+g1+g2;
a[3]=b1+b2+c2+c3+g1+g3;
a[4]=b1+b3+c1+c2+g3+g2;
a[5]=b2+b1+c1+c3+g3+g2;
for(i=0;i<6;i++){
if(i==0)
min=a[i];
else if(min>a[i])
min=a[i];
}
for(i=0;i<6;i++){
if(a[i]==min){
if(i==0) cout<<"BCG ";
else if(i==1) cout<<"BGC ";
else if(i==2) cout<<"CBG ";
else if(i==3) cout<<"CGB ";
else if(i==4) cout<<"GBC ";
else if(i==5) cout<<"GCB ";
cout<<a[i]<<endl;
break;
}
}
}
return 0;
}