1 #include<cstdio>
2 #include<iostream>
3 #include<algorithm>
4 #include<queue>
5 #include<map>
6 #include<vector>
7 #include<set>
8 #include<string>
9 #include<cmath>
10 #include<cstring>
11 using namespace std;
12 typedef struct{
13 int x;
14 int y;
15 int z;
16 }t;
17 t tt[100];
18 bool cmp(t t1,t t2)
19 {
20 if(t1.x!=t2.x)
21 return t1.x<t2.x;
22 else if(t1.y!=t2.y)
23 return t1.y<t2.y;
24 else return t1.z<t2.z;
25 }
26 int n;
27 int dp[100];
28 int main()
29 {
30 int c=1;
31 while(~scanf("%d",&n)&&n!=0)
32 {
33 int cnt=0;
34 for(int i=0;i<n;i++)
35 {
36 int a,b,c;
37 scanf("%d%d%d",&a,&b,&c);
38 {//一组数据有6种情况
39 tt[cnt].x=a;
40 tt[cnt].y=b;
41 tt[cnt++].z=c;
42
43 tt[cnt].x=a;
44 tt[cnt].y=c;
45 tt[cnt++].z=b;
46
47 tt[cnt].x=b;
48 tt[cnt].y=a;
49 tt[cnt++].z=c;
50
51 tt[cnt].x=b;
52 tt[cnt].y=c;
53 tt[cnt++].z=a;
54
55 tt[cnt].x=c;
56 tt[cnt].y=a;
57 tt[cnt++].z=b;
58
59 tt[cnt].x=c;
60 tt[cnt].y=b;
61 tt[cnt++].z=a;
62 }
63 }
64 sort(tt,tt+cnt,cmp);
65
66 dp[0]=tt[0].z;
67 int res=0;
68 for(int i=0;i<cnt;i++)
69 {
70 int maxx=0;
71
72 for(int j=0;j<i;j++)
73 {
74 if(tt[i].x>tt[j].x&&tt[i].y>tt[j].y)
75 {
76 // printf(" i=%d j=%d\n",i,j);
77
78 maxx=max(maxx,dp[j]);
79 }
80
81 }
82 dp[i]=tt[i].z+maxx;
83 res=max(res,dp[i]);
84 }
85
86 printf("Case %d: maximum height = %d\n",c++,res);
87 }
88 return 0;
89 }
hdu1069 Monkey and Banana LIS
最新推荐文章于 2024-08-01 13:27:05 发布