forked from fatemehkarimi/uvaSolutions
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuva-102.cpp
More file actions
69 lines (53 loc) · 1.33 KB
/
uva-102.cpp
File metadata and controls
69 lines (53 loc) · 1.33 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
64
65
66
67
68
69
//Ecological Bin Packing
//UVa 102
#include <iostream>
#include <string>
using namespace std;
int main(void)
{
while (true) {
long long int arr[3][3] = {};
for (int i = 0; i < 3; ++i)
for (int j = 0; j < 3; ++j)
if (cin >> arr[i][j]);
else
return 0;
long long int answer = 0;
string str;
//case 1. BCG
answer = arr[1][0] + arr[2][0] + arr[0][2] + arr[2][2] + arr[0][1] + arr[1][1];
str = "BCG";
//case 2. BGC
long long int temp = 0;
temp = arr[1][0] + arr[2][0] + arr[2][1] + arr[0][1] + arr[0][2] + arr[1][2];
if (temp < answer) {
answer = temp;
str = "BGC";
}
//case 3. CBG
temp = arr[1][2] + arr[2][2] + arr[2][0] + arr[0][0] + arr[0][1] + arr[1][1];
if (temp < answer) {
answer = temp;
str = "CBG";
}
//case 4. CGB
temp = arr[1][2] + arr[2][2] + arr[0][1] + arr[2][1] + arr[0][0] + arr[1][0];
if (temp < answer) {
answer = temp;
str = "CGB";
}
//case 5. GBC
temp = arr[1][1] + arr[2][1] + arr[0][0] + arr[2][0] + arr[0][2] + arr[1][2];
if (temp < answer) {
answer = temp;
str = "GBC";
}
//case 6. GCB
temp = arr[1][1] + arr[2][1] + arr[0][2] + arr[2][2] + arr[0][0] + arr[1][0];
if (temp < answer) {
answer = temp;
str = "GCB";
}
cout << str << ' ' << answer << endl;
}
}