poj3176--Cow Bowling(dp:数塔问题)
| Time Limit: 1000MS | Memory Limit: 65536K | |
| Total Submissions: 14028 | Accepted: 9302 | 
Description
          7
        3   8
      8   1   0
    2   7   4   4
  4   5   2   6   5
Then the other cows traverse the triangle starting from its tip and moving "down" to one of the two diagonally adjacent cows until the "bottom" row is reached. The cow's score is the sum of the numbers of the cows visited along the way. The cow with the highest
 score wins that frame. 
Given a triangle with N (1 <= N <= 350) rows, determine the highest possible sum achievable.
Input
Lines 2..N+1: Line i+1 contains i space-separated integers that represent row i of the triangle.
Output
Sample Input
5
7
3 8
8 1 0
2 7 4 4
4 5 2 6 5
Sample Output
30
Hint
          7
         *
        3   8
       *
      8   1   0
       *
    2   7   4   4
       *
  4   5   2   6   5
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int dp[400][400] ;
int main()
{
int n , i , j , max1 ;
while(scanf("%d", &n) !=EOF)
{
max1 = 0 ;
memset(dp,0,sizeof(dp));
for(i = 1 ; i <= n ; i++)
for(j = 1 ; j <= i ; j++)
scanf("%d", &dp[i][j]);
for(i = 1 ; i <= n ; i++)
for(j = 1 ; j <= i ; j++)
dp[i][j] = max( dp[i-1][j-1],dp[i-1][j] ) + dp[i][j] ;
for(i = 1 ; i <= n ; i++)
max1 = max(max1,dp[n][i]);
printf("%d\n", max1);
}
return 0;
}
poj3176--Cow Bowling(dp:数塔问题)的更多相关文章
- poj-3176 Cow Bowling &&poj-1163 The Triangle && hihocoder #1037 : 数字三角形 (基础dp)
		
经典的数塔模型. 动态转移方程: dp[i][j]=max(dp[i+1][j],dp[i+1][j+1])+p[i][j]; #include <iostream> #include ...
 - POJ3176——Cow Bowling(动态规划)
		
Cow Bowling DescriptionThe cows don't use actual bowling balls when they go bowling. They each take ...
 - POJ 3176 Cow Bowling(dp)
		
POJ 3176 Cow Bowling 题目简化即为从一个三角形数列的顶端沿对角线走到底端,所取得的和最大值 7 * 3 8 * 8 1 0 * 2 7 4 4 * 4 5 2 6 5 该走法即为最 ...
 - HDU2084基础DP数塔
		
数塔 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submissi ...
 - UVA 116 Unidirectional TSP(dp + 数塔问题)
		
Unidirectional TSP Background Problems that require minimum paths through some domain appear in ma ...
 - POJ3176 Cow Bowling                                                                                            2017-06-29 14:33             23人阅读              评论(0)              收藏
		
Cow Bowling Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 19173 Accepted: 12734 Des ...
 - Poj3176 Cow Bowling (动态规划 数字三角形)
		
Description The cows don't use actual bowling balls when they go bowling. They each take a number (i ...
 - HDU 1176免费馅饼     DP数塔问题转化
		
L - 免费馅饼 Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit Sta ...
 - DP~数塔(hrbustoj1004)
		
aaarticlea/bmp;base64,iVBORw0KGgoAAAANSUhEUgAAAtQAAAPgCAYAAAASsev/AAAgAElEQVR4nOzdf4w0x33n9/4rQP4L8s
 
随机推荐
- TCP/IP协议的编写《转载》
			
基于HHARM9-EDU的TCP/IP(UDP)协议的实现 原文网址:http://blog.csdn.net/lhj0503/article/details/3323788 摘 要:嵌入式技术的发展 ...
 - javascript中apply和eval结合的强大用法
			
eval是一个函数,可以接受一个参数,这个参数可以作为js语句被解释性的执行,利用这个特性,eval和apply结合起来,可以大大简化代码 如下例子 <a class="cl ...
 - Type Unknown error: java.lang.NullPointerException
			
Android 项目开发的时候 出现: Description Resource Path Location Type Unknown error: java.lang.NullPointerExce ...
 - win7下不能收到窗口hook消息的问题
			
win7下由于UIPI的限制, 高权限进程无法收到底权限进程发来的消息, 因此对窗口消息hook时无法接收到消息,解决办法是在调用SetWindowsHookEx之前先调用ChangeWindowMe ...
 - opencv做的美女找茬程序~
			
// CMP.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <cv.h> #include <high ...
 - WPF入门介绍
			
Windows Vista已经于2007年1月30正式发行零售版本,安装Vista的计算机将会大量出现.在Vista时代,身为编程员,就一定要具备Vista桌面应用开发的能力.而开发Vista桌面应用 ...
 - 用Delphi画圆角Panel的方法(使用CreateRoundRectRgn创造区域,SetWindowRgn显示指定区域)
			
用Delphi画圆角Panel的方法: procedure TForm1.Button5Click(Sender: TObject);var fhr :Thandle;beginfhr:=Create ...
 - 理解Windows内核模式与用户模式
			
 1.基础 执行 Windows 的计算机中的处理器有两个不同模式:"用户模式"和"内核模式". 依据处理器上执行的代码的类型,处理器在两个模式之间切换.应 ...
 - Android源代码分析-资源载入机制
			
转载请注明出处:http://blog.csdn.net/singwhatiwanna/article/details/23387079 (来自singwhatiwanna的csdn博客) 前言 我们 ...
 - HDU 1535 Invitation Cards (POJ 1511)
			
两次SPFA. 求 来 和 回 的最短路之和. 用Dijkstra+邻接矩阵确实好写+方便交换.可是这个有1000000个点.矩阵开不了. d1[]为 1~N 的最短路. 将全部边的 邻点 交换. d ...