poj1163解题报告
来源:互联网 发布:php hashmap的实现原理 编辑:程序博客网 时间:2024/06/05 16:48
经典的动态规划,分析省略不懂的完全可以百度(数字三角形),仅给出AC代码Memory 260k time 32ms
#include<cstdio>#include<cstring>#include<algorithm>using namespace std;const int maxn=100+10;int dp[maxn][maxn],a[maxn][maxn];int main(){ int n; scanf("%d",&n); memset(dp,0,sizeof(dp)); for(int i=0;i<n;i++) for(int j=0;j<=i;j++) scanf("%d",&a[i][j]); for(int i=0;i<n;i++) dp[n-1][i]=a[n-1][i]; for(int i=n-2;i>=0;i--) for(int j=0;j<=i;j++) dp[i][j]=max(a[i][j]+dp[i+1][j],a[i][j]+dp[i+1][j+1]); printf("%d\n",dp[0][0]); return 0;}
1 0
- poj1163解题报告
- 【Jason's_ACM_解题报告】The Triangle(POJ1163)
- 【ACM菜逼解题报告】The Triangle(POJ1163)
- POJ1163
- poj1163
- POJ1163
- POJ1163
- POJ1163
- poj1163
- poj1163
- POJ1163
- poj1163
- poj1163
- poj1163
- poj1163
- POJ1163
- Poj1163
- poj1163
- TortoiseGit记住密码
- Ubuntu 14.04.1安装mysql以及配置
- C++回炉(1)
- 为什么嵌入式C语言编程要有编码规范
- 京东量化第二次线上分享会又来啦
- poj1163解题报告
- JavaSE 学习参考:HashMap和Hashtable的区别
- C++抽象工厂模式
- matplotlib-绘制精美的图表
- MySQL数据库入门(五)
- HTTP,HTTPS协议知识点总结
- ZOJ 3872 Beauty of Array
- java中为神魔提供基本类型的类封装
- Unity自带WWW Get与Post的方式获得数据