poj3176--Cow Bowling(dp:数塔问题)
2015-12-24 15:12
267 查看
Cow Bowling
Description
The cows don't use actual bowling balls when they go bowling. They each take a number (in the range 0..99), though, and line up in a standard bowling-pin-like triangle like this:
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
Line 1: A single integer, N
Lines 2..N+1: Line i+1 contains i space-separated integers that represent row i of the triangle.
Output
Line 1: The largest sum achievable using the traversal rules
Sample Input
Hint
Explanation of the sample:
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 14028 | Accepted: 9302 |
The cows don't use actual bowling balls when they go bowling. They each take a number (in the range 0..99), though, and line up in a standard bowling-pin-like triangle like this:
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
Line 1: A single integer, N
Lines 2..N+1: Line i+1 contains i space-separated integers that represent row i of the triangle.
Output
Line 1: The largest sum achievable using the traversal rules
Sample Input
30
Hint
Explanation of the sample:
7 * 3 8 * 8 1 0 * 2 7 4 4 * 4 5 2 6 5
相关文章推荐
- 线性模型——异方差、序列相关、多重共线性与内生性的处理
- iOS之浅谈纯代码控制UIViewController视图控制器跳转界面的几种方法
- jquery 选择对象随心所欲,遍历数组更是易如反掌
- Android屏幕适配全攻略(最权威的官方适配指导)
- highcharts跟后台交互的demo
- 73、STP安全配置实验之BPDU Filtering
- uva10098 Generating Fast
- 仿写的类似支付宝二维码扫描的简单例子
- centos 6.4安装cmake
- Swift :?和 !
- Convert InputStream to JSONObject
- Undefined symbols: _SCNetworkReachabilityCreateWithName
- 快速定位死循环位置
- Mybatis - 查询缓存(一级缓存,二级缓存,与ehcache整合)
- ORA-27300: OS system dependent operation:spcdr:9261:4200 failed with status: 997
- 在网页中显示器PDF文档
- php5中public,private,protected 三种类属性的区别
- stty 命令说明及使用讲解
- Java基础创建文件及目录
- ArcEngine 无法将类型为"Systerm._ComObject"的对象强制转换为类型******