-
Notifications
You must be signed in to change notification settings - Fork 0
/
102 - Ecological Bin Packing.cpp
68 lines (65 loc) · 1.19 KB
/
102 - Ecological Bin Packing.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
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
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<queue>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<map>
#include<set>
#define ll long long
#define sc scanf
#define pf printf
#define Pi 2*acos(0.0)
using namespace std;
int main()
{
long int a[3][3],move[6],sum=0,min;
int p,n,f,i,j;
while(1)
{
sum=0;f=1;
for(i=0;i<3;i++){
for(j=0;j<3;j++){
n=sc("%ld",&a[i][j]);
if(n==EOF){
f=0;
break;
}
sum=sum+a[i][j];
}
}
if(f==0)
break;
move[0]=a[0][0]+a[1][2]+a[2][1];
move[1]=a[0][0]+a[1][1]+a[2][2];
move[2]=a[0][2]+a[1][0]+a[2][1];
move[3]=a[0][2]+a[1][1]+a[2][0];
move[4]=a[0][1]+a[1][0]+a[2][2];
move[5]=a[0][1]+a[1][2]+a[2][0];
for(i=0;i<6;i++)
move[i]=sum-move[i];
min=move[0];
p=0;
for(i=1;i<6;i++)
if(min>move[i])
{
min=move[i];
p=i;
}
if(p==0)
pf("BCG %ld\n",min);
else if(p==1)
pf("BGC %ld\n",min);
else if(p==2)
pf("CBG %ld\n",min);
else if(p==3)
pf("CGB %ld\n",min);
else if(p==4)
pf("GBC %ld\n",min);
else if(p==5)
pf("GCB %ld\n",min);
}
return 0;
}