UVA 437 The Tower of Babylon DP+记忆化
来源:互联网 发布:剑灵高冷正太捏脸数据 编辑:程序博客网 时间:2024/06/10 09:46
#include <map>#include <set>#include <list>#include <cmath>#include<cctype>#include <ctime>#include <deque>#include <stack>#include <queue>#include <cstdio>#include <string>#include <vector>#include <cstdlib>#include <cstring>#include <iostream>#include <algorithm>#define LL long long#define PI 3.1415926535897932626using namespace std;int gcd(int a, int b){return a % b == 0 ? b : gcd(b, a % b);}int l[120],c[120],h[120];int N,cas;int dp[120];int calcu(int index){ if (dp[index]!=-1) return dp[index]; dp[index]=h[index]; for (int i=0;i<cas;i++) { //if (i==index)continue; if (l[i]>l[index] && c[i]>c[index]) dp[index]=max(dp[index],calcu(i)+h[index]); } return dp[index];}int main(){ //freopen("sample.txt","r",stdin); int kase=1; while (scanf("%d",&N)!=EOF) { if (N==0) break; cas=0;int a[4]; for (int i=0;i<N;i++) { scanf("%d%d%d",&a[0],&a[1],&a[2]); sort(a,a+3); //for (int j=0;j<3;j++) printf("%d\n",a[j]); l[cas]=a[1];c[cas]=a[0];h[cas]=a[2];cas++; l[cas]=a[2];c[cas]=a[0];h[cas]=a[1];cas++; l[cas]=a[2];c[cas]=a[1];h[cas]=a[0];cas++; } int ans=-1; memset(dp,-1,sizeof(dp)); for (int i=0;i<cas;i++) ans=max(ans,calcu(i)); printf("Case %d: maximum height = %d\n",kase++,ans); } return 0;}
0 0
- uva 437 The Tower of Babylon(dp,记忆化搜索)
- UVA 437 The Tower of Babylon DP+记忆化
- uva 10285 The Tower of Babylon(dp,记忆化搜索)
- Uva-437 The Tower of Babylon DP
- UVA 437 The Tower of Babylon | dp
- uva--437The Tower of Babylon+dp
- UVA 437 The Tower of Babylon DP
- DP--UVA - 437 The Tower of Babylon
- UVa--437 The Tower of Babylon(dp)
- UVA 437 The Tower of Babylon 【dp】
- UVa 437.The Tower of Babylon【记忆化搜索+dp】【4月25】
- uva 10285 The Tower of Babylon(记忆化搜索)
- uva 437 The Tower of Babylon(DAG的DP)
- UVA 437The Tower of Babylon (dp + DAG最长序列)
- uva 437 - The Tower of Babylon(DP)
- UVa 437 The Tower of Babylon (DP&DAG)
- UVA 437 (POJ 2241) The Tower of Babylon(DP)
- Uva 437-The Tower of Babylon(DP)
- 静态初始化,非静态初始化
- 梦想黑马程序员__夜雨飘零的心绪
- NPAPI插件开发学习:NPAPI的运行流程
- 浅谈msp430f5529入门(1)——时钟模块DCO
- Maven + (Spring + Hibernate) Annotation + MySQL项目
- UVA 437 The Tower of Babylon DP+记忆化
- git 使用说明一:初始化设置
- 代理
- subVersion 版本控制系统搭建与使用
- 黑马程序员---Java Collection Framework
- 关于 优先队列 得有关库函数( priority_queue)
- 关于框架的一些胡思乱想
- NPAPI 插件研究经验总结
- ARM学习--ARM程序设计