hdu 1069 monkey and banana(最长下降子序列)
来源:互联网 发布:unity3d 古代建筑模型 编辑:程序博客网 时间:2024/06/05 07:08
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1069
思路:最长下降子序列
#include<cstdio>#include<cstring>#include<algorithm>using namespace std;const int num=200;struct node{ int x,y,z;}data[num];int cnt,dp[num];void add(int a,int b,int c){ data[cnt].x=a; data[cnt].y=b; data[cnt++].z=c;}bool cmp(const node a,const node b){ if(a.x!=b.x) return a.x>b.x; else if(a.y!=b.y) return a.y>b.y; else return a.z>b.z;}int ok(int a,int b){ if(data[a].x>data[b].x&&data[a].y>data[b].y) return 1; return 0;}int main(){ int n,i,j,a,b,c,cas=0,tmp,ans; //freopen("in.txt","r",stdin); while(scanf("%d",&n)!=EOF) { if(n==0) break; cnt=0; cas++; for(i=0;i<n;i++) { scanf("%d%d%d",&a,&b,&c); add(a,b,c); add(a,c,b); add(b,a,c); add(b,c,a); add(c,a,b); add(c,b,a); } sort(data,data+cnt,cmp); dp[0]=data[0].z; for(i=1;i<cnt;i++) { tmp=0; for(j=0;j<i;j++) if(ok(j,i)&&dp[j]>tmp) tmp=dp[j]; dp[i]=tmp+data[i].z; } ans=0; for(i=0;i<cnt;i++) if(dp[i]>ans) ans=dp[i]; printf("Case %d: maximum height = %d\n",cas,ans); } return 0;}
0 0
- hdu 1069 monkey and banana(最长下降子序列)
- hdu 1069 Monkey and Banana(最长递减子序列 )
- hdu 1069 Monkey and Banana--最长递增子序列
- HDU 1069 Monkey and Banana (最长上升子序列)
- hdu 1069 Monkey and Banana(dp 最长上升子序列)
- hdu 1069 Monkey and Banana 最长上升子序列。
- HDU 1069 Monkey and Banana (类似最长递增子序列)
- HDU 1069 Monkey and Banana 最长上升子序列模板
- HDU 1069 Monkey and Banana (dp, 最长上升子序列)
- Monkey and Banana (最长子序列)
- (博客搬迁)hdu1069 Monkey and Banana(最长不下降子序列)
- hdu 1069 Monkey and Banana(类似最长上升子序列,dp)
- HDU 1069 Monkey and Banana(dp最长上升子序列)
- HDU 1069 Monkey and Banana(最大下降子序列和变形)
- HDU Monkey and Banana 1069 dp 动态规划 最长递增子序列
- 三维最长上升子序列问题——HDU 1069 Monkey and Banana
- HDU 1069 Monkey and Banana dp类型:最长上升子序列
- hdu 1069 Monkey and Banana(最长递增子序列的变形)
- 再解 KMP(初学)
- android自定义控件findViewById为空
- ubuntu安装启动redis
- Redis作为缓存总结
- linux文件属性详解
- hdu 1069 monkey and banana(最长下降子序列)
- 是苦还是个体喔唷兔兔后itot
- springbatch操作CSV文件
- codeforces 158B Taxi (贪心)
- 人生就像公交车——真的很经典
- vdceye onvif manager 软件架构图
- 是理科的关键看机会了如今也已
- 用SecureCRT来上传和下载文件
- drbd