hdu1069 Monkey and Banana LIS
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 }
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
2019-02-14 UVA 10763 Foreign Exchange
2019-02-14 UVA 10935 Throwing cards away I
2019-02-14 UVA 1593 Alignment of Code
2019-02-14 UVA 221 Urban Elevations