poj 1163__The Triangle(dp)
来源:互联网 发布:javascript基础入门 编辑:程序博客网 时间:2024/06/15 18:41
The Triangle
Time Limit: 1000MS Memory Limit: 10000KTotal Submissions: 41674 Accepted: 25203
Description
73 88 1 02 7 4 44 5 2 6 5(Figure 1)
Input
Your program is to read from standard input. The first line contains one integer N: the number of rows in the triangle. The following N lines describe the data of the triangle. The number of rows in the triangle is > 1 but <= 100. The numbers in the triangle, all integers, are between 0 and 99.
Output
Your program is to write to standard output. The highest sum is written as an integer.
Sample Input
573 88 1 0 2 7 4 44 5 2 6 5
Sample Output
30
Source
IOI 1994
#include<cstdio>#include<algorithm>#include<cstring>using namespace std;int main(){ int n,m; int a[110][110],dp[110][110]; while(~scanf("%d",&n)) { for(int i=1;i<=n;i++) { for(int j=1;j<=i;j++) { scanf("%d",&a[i][j]); } } memset(dp,0,sizeof(dp)); for(int i=1;i<=n;i++) { for(int j=1;j<=i;j++) { dp[i][j]=max(dp[i-1][j-1],dp[i-1][j])+a[i][j]; } } int MAX=-1; for(int i=1;i<=n;i++) { if(MAX<dp[n][i]) { MAX=dp[n][i]; } } printf("%d\n",MAX); } return 0;}
0 0
- poj 1163__The Triangle(dp)
- POJ 1163 The Triangle (DP)
- POJ 1163 The Triangle【DP】
- poj 1163 The Triangle【dp】
- [DP] POJ 1163 The Triangle
- POJ 1163 The Triangle DP
- poj 1163 The Triangle --dp
- POJ 1163 The Triangle [DP]
- poj 1163 The Triangle 基础DP
- POJ 1163 The Triangle 简单DP
- DP专题1 POJ 1163 The Triangle
- poj 1163The Triangle(水dp)
- POJ 1163 The Triangle 简单DP
- POJ 1163 The Triangle (简单DP)
- POJ 1163 The Triangle DP题解
- ACM POJ 1163 The Triangle DP
- poj - 1163 - The Triangle(dp)
- POJ 1163 The Triangle (DP)
- 移动硬盘挂载后访问权限修改
- 在PCL中使用直通滤波器对点云进行滤波处理
- poj 1017 Packets
- 图文解释XCode常用快捷键的使用
- 编程资料
- poj 1163__The Triangle(dp)
- ARM64的启动过程之(二):创建启动阶段的页表
- 增加字段改为主键后:1062-Duplicate entry '' for key 'PRIMARY'
- 【bzoj1355】【Baltic2009】【Radio Transmission】【kmp】
- 上下状态切换 1和0切换
- USB枚举详细过程剖析
- 下拉刷新
- BZOJ1054[HAOI]移动玩具|状态压缩SPFA
- Cocos2D v2.0至v3.x简洁转换指南(二)