-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path102.cpp
More file actions
75 lines (65 loc) · 1.52 KB
/
Copy path102.cpp
File metadata and controls
75 lines (65 loc) · 1.52 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
70
71
72
73
74
75
// Author: btjanaka (Bryon Tjanaka)
// Problem: (UVa) 102
#include <bits/stdc++.h>
using namespace std;
int bins[3][3]; // Brown, green, clear
int take_bins() {
int tot = 0;
for (int i = 0; i < 3; ++i) {
for (int j = 0; j < 3; ++j) {
tot += scanf("%d", &bins[i][j]);
}
}
return tot;
}
int main() {
while (take_bins() > 0) {
long long tot = 1L << 33;
long long tmp = 0;
char res[10];
// GCB
tmp = bins[1][1] + bins[2][1] + bins[0][2] + bins[2][2] + bins[0][0] +
bins[1][0];
if (tmp <= tot) {
tot = tmp;
strcpy(res, "GCB");
}
// GBC
tmp = bins[1][1] + bins[2][1] + bins[0][0] + bins[2][0] + bins[0][2] +
bins[1][2];
if (tmp <= tot) {
tot = tmp;
strcpy(res, "GBC");
}
// CGB
tmp = bins[1][2] + bins[2][2] + bins[0][1] + bins[2][1] + bins[0][0] +
bins[1][0];
if (tmp <= tot) {
tot = tmp;
strcpy(res, "CGB");
}
// CBG
tmp = bins[1][2] + bins[2][2] + bins[0][0] + bins[2][0] + bins[0][1] +
bins[1][1];
if (tmp <= tot) {
tot = tmp;
strcpy(res, "CBG");
}
// BGC
tmp = bins[1][0] + bins[2][0] + bins[0][1] + bins[2][1] + bins[0][2] +
bins[1][2];
if (tmp <= tot) {
tot = tmp;
strcpy(res, "BGC");
}
// BCG
tmp = bins[1][0] + bins[2][0] + bins[0][2] + bins[2][2] + bins[0][1] +
bins[1][1];
if (tmp <= tot) {
tot = tmp;
strcpy(res, "BCG");
}
printf("%s %lld\n", res, tot);
}
return 0;
}