-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy path102.cpp
More file actions
executable file
·63 lines (48 loc) · 1.29 KB
/
102.cpp
File metadata and controls
executable file
·63 lines (48 loc) · 1.29 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/* Problem: Ecological Bin Packing UVa 102
Programmer: Md. Mahmud Ahsan
Compiled: Visual C++ 6.0
Date: 25-08-04
*/
#include <iostream>
#include <string>
using namespace std;
// struct type
struct Bin{
char style[4];
int amount;
};
//prototype
void printOutput(Bin obj[]);
//=================================================================
int main(){
int a, b, c, d, e, f, g, h, i;
while (cin >> a >> b >> c >> d >> e >> f >> g >> h >> i){
Bin obj[6];
strcpy(obj[0].style, "BCG");
obj[0].amount = d + g + c + i + b + e;
strcpy(obj[1].style, "BGC");
obj[1].amount = d + g + b + h + c + f;
strcpy(obj[2].style, "CBG");
obj[2].amount = f + i + a + g + b + e;
strcpy(obj[3].style, "CGB");
obj[3].amount = f + i + b + h + a + d;
strcpy(obj[4].style, "GBC");
obj[4].amount = e + h + a + g + c + f;
strcpy(obj[5].style, "GCB");
obj[5].amount = e + h + c + i + a + d;
printOutput(obj);
}
return 0;
}
//======================================================================
void printOutput(Bin obj[]){
int temp = obj[0].amount;
int flag = 0;
for (int i = 1; i < 6; i++){
if (temp > obj[i].amount){
temp = obj[i].amount;
flag = i;
}
}
cout << obj[flag].style << " " << obj[flag].amount << endl;
}