POJ 3176:Cow Bowling
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 13464 | Accepted: 8897 |
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
The highest score is achievable by traversing the cows as shown above.
简单的数塔DP问题。
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream> using namespace std; const int M = 350 +5;
int Cow[M][M]; int main()
{
int n;
while(scanf("%d", &n)!=EOF)
{
memset(Cow, 0, sizeof(Cow));
for(int i=1; i<=n; i++)
for(int j=1; j<=i; j++)
{
scanf("%d", &Cow[i][j]);
}
for(int i=n-1; i>=1; i--)
for(int j=1; j<=i; j++)
Cow[i][j]+=max(Cow[i+1][j], Cow[i+1][j+1]);
cout<<Cow[1][1]<<endl;
} return 0;
}
POJ 3176:Cow Bowling的更多相关文章
- 【POJ 3176】Cow Bowling
题 Description The cows don't use actual bowling balls when they go bowling. They each take a number ...
- 【POJ 3176】Cow Bowling(DP)
题 Description The cows don't use actual bowling balls when they go bowling. They each take a number ...
- POJ 3673:Cow Multiplication
Cow Multiplication Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 12210 Accepted: 85 ...
- POJ 2184:Cow Exhibition(01背包变形)
题意:有n个奶牛,每个奶牛有一个smart值和一个fun值,可能为正也可能为负,要求选出n只奶牛使他们smart值的和s与fun值得和f都非负,且s+f值要求最大. 分析: 一道很好的背包DP题,我们 ...
- POJ 3176 Cow Bowling(dp)
POJ 3176 Cow Bowling 题目简化即为从一个三角形数列的顶端沿对角线走到底端,所取得的和最大值 7 * 3 8 * 8 1 0 * 2 7 4 4 * 4 5 2 6 5 该走法即为最 ...
- poj 1163 The Triangle &poj 3176 Cow Bowling (dp)
id=1163">链接:poj 1163 题意:输入一个n层的三角形.第i层有i个数,求从第1层到第n层的全部路线中.权值之和最大的路线. 规定:第i层的某个数仅仅能连线走到第i+1层 ...
- POJ 3176 Cow Bowling
Cow Bowling Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 13016 Accepted: 8598 Desc ...
- POJ 3176 简单DP
Cow Bowling Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 16448 Accepted: 10957 Descrip ...
- POJ 3617 Best Cow Line(最佳奶牛队伍)
POJ 3617 Best Cow Line Time Limit: 1000MS Memory Limit: 65536K [Description] [题目描述] FJ is about to t ...
随机推荐
- WCF技术剖析之三十:一个很有用的WCF调用编程技巧[下篇]
原文:WCF技术剖析之三十:一个很有用的WCF调用编程技巧[下篇] 在<上篇>中,我通过使用Delegate的方式解决了服务调用过程中的异常处理以及对服务代理的关闭.对于<WCF技术 ...
- 用c++开发基于tcp协议的文件上传功能
用c++开发基于tcp协议的文件上传功能 2005我正在一家游戏公司做程序员,当时一直在看<Windows网络编程> 这本书,把里面提到的每种IO模型都试了一次,强烈推荐学习网络编程的同学 ...
- Recipes — Bottle 0.13-dev documentation
Recipes - Bottle 0.13-dev documentation Recipes¶ This is a collection of code snippets and examples ...
- sn9c291 驱动载入成功,mpayer无法播放
先眼下将一个sn9c291+ov9712的模块驱动在fedora上载入成功,但是在使用mplayer却无法播放,不知道为何? watermark/2/text/aHR0cDovL2Jsb2cuY3Nk ...
- [放松一下] 经典高清电影合集 170G BT种子下载
经典高清电影合集 170G BT种子下载 点击文件名下载 经典高清电影合集170G BT种子.torrent 下载方法 经典高清电影合集详情见目录: 1. 杀手47 2. 这个杀手不太冷 3. 放牛班 ...
- SDL2源码分析6:拷贝到渲染器(SDL_RenderCopy())
===================================================== SDL源码分析系列文章列表: SDL2源码分析1:初始化(SDL_Init()) SDL2源 ...
- ASP.NET Core 中文文档
ASP.NET Core 中文文档 翻译计划 五月中旬 .NET Core RC2 如期发布,我们遂决定翻译 ASP.NET Core 文档.我们在 何镇汐先生. 悲梦先生. 张仁建先生和 雷欧纳德先 ...
- 14.19 InnoDB and MySQL Replication InnoDB 和MySQL 复制:
14.19 InnoDB and MySQL Replication InnoDB 和MySQL 复制: MySQL 复制工作对于InnoDB 表和对于MyISAM表. 它是可能使用复制的方式 存储引 ...
- Koa -- 基于 Node.js 平台的下一代 web 开发框架
http://koa.bootcss.com/ 多研究点 react 和 nodejs 这个是未来
- Swift - 多线程实现方式(1) - NSThread
1,Swift继续使用Object-C原有的一套线程,包括三种多线程编程技术: (1)NSThread (2)Cocoa NSOperation(NSOperation和NSOperationQueu ...