-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEcologicalBinPacking.cpp
More file actions
32 lines (30 loc) · 875 Bytes
/
Copy pathEcologicalBinPacking.cpp
File metadata and controls
32 lines (30 loc) · 875 Bytes
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
#include <bits/stdc++.h>
using namespace std;
int main() {
int b[3];
int g[3];
int c[3];
while(scanf("%d %d %d %d %d %d %d %d %d",
b,g,c,b+1,g+1,c+1,b+2,g+2,c+2) != EOF){
string cur = "BCG";
string best = "ZZZ";
int bestCnt = INT_MAX;
// BCG
do{
int cost = 0;
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
if(i==j) continue;
if(cur[i] == 'B') cost += b[j];
else if(cur[i] == 'C') cost += c[j];
else if(cur[i] == 'G') cost += g[j];
}
}
if(cost < bestCnt) {
bestCnt = cost;
best = cur;
}
}while(next_permutation(cur.begin(),cur.end()));
cout << best << " " << bestCnt << endl;
}
}