POJ3176 Cow Bowling 2017-06-29 14:33 23人阅读 评论(0) 收藏
| Time Limit: 1000MS | Memory Limit: 65536K | |
| Total Submissions: 19173 | Accepted: 12734 | 
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.
Source
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <climits> using namespace std; #define LL long long
const int INF = 0x3f3f3f3f; int dp[400][400];
int a[400][400];
int n;
int main()
{
scanf("%d",&n);
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;
}
POJ3176 Cow Bowling 2017-06-29 14:33 23人阅读 评论(0) 收藏的更多相关文章
- 第十二届浙江省大学生程序设计大赛-May Day Holiday                                                       分类:            比赛             2015-06-26 14:33    10人阅读    评论(0)    收藏
		
May Day Holiday Time Limit: 2 Seconds Memory Limit: 65536 KB As a university advocating self-learnin ...
 - Beautiful People                                                    分类:            Brush Mode             2014-10-01 14:33    100人阅读    评论(0)    收藏
		
Beautiful People Time Limit: 10000/5000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others) ...
 - NYOJ-456 邮票分你一半  AC                                                    分类:            NYOJ             2014-01-02 14:33    152人阅读    评论(0)    收藏
		
#include<stdio.h> #define max(x,y) x>y?x:y int main(){ int n,x,y; scanf("%d",& ...
 - A Knight's Journey                                                    分类:            dfs             2015-05-03 14:51    23人阅读    评论(0)    收藏
		
A Knight’s Journey Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 34085 Accepted: 11621 ...
 - Hadoop入门经典:WordCount                                                    分类:            A1_HADOOP             2014-08-20 14:43    2514人阅读    评论(0)    收藏
		
以下程序在hadoop1.2.1上测试成功. 本例先将源代码呈现,然后详细说明执行步骤,最后对源代码及执行过程进行分析. 一.源代码 package org.jediael.hadoopdemo.wo ...
 - iOS正则表达式                                                    分类:            ios技术             2015-07-14 14:00    35人阅读    评论(0)    收藏
		
一.什么是正则表达式 正则表达式,又称正规表示法,是对字符串操作的一种逻辑公式.正则表达式可以检测给定的字符串是否符合我们定义的逻辑,也可以从字符串中获取我们想要的特定部分.它可以迅速地用极简单的方式 ...
 - Hdu2181 哈密顿绕行世界问题                                                                                            2017-01-18 14:46             45人阅读              评论(0)              收藏
		
哈密顿绕行世界问题 Time Limit : 3000/1000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other) Total Sub ...
 - Lucene学习总结之四:Lucene索引过程分析                                        2014-06-25 14:18    884人阅读    评论(0)    收藏
		
对于Lucene的索引过程,除了将词(Term)写入倒排表并最终写入Lucene的索引文件外,还包括分词(Analyzer)和合并段(merge segments)的过程,本次不包括这两部分,将在以后 ...
 - MS SQL数据批量备份还原(适用于MS SQL 2005+)                                                    分类:            SQL Server 数据库             2015-03-10 14:32    103人阅读    评论(0)    收藏
		
我们知道通过Sql代理,可以实现数据库的定时备份功能:当数据库里的数据库很多时,备份一个数据库需要建立对应的定时作业,相对来说比较麻烦: 还好,微软自带的osql工具,比较实用,通过在命令行里里输入命 ...
 
随机推荐
- Activity和Intent
 - How to Solve Lonsdor K518ISE Abnormal Display by Factory Resetting
			
Here’s the working solution to Lonsdor K518ISE Key Programmer abnormal display after upgrade. Proble ...
 - 立即响应ScrollView上的子视图的手势
			
self.myScrollView.delaysContentTouches = YES; self.myScrollView.CanCancelContentTouches=NO; 写了一个继承sc ...
 - nodejs 如何操作字节在内存中的位置问题 BE LE
			
上代码 function testNumber() { var arr = new Int32Array(1); arr[0] = 1234; var buf1 = Buffer.from(arr); ...
 - qt小程序
			
hello: #include <QApplication> #include <QLabel> int main(int argc, char *argv[]) { QApp ...
 - 用 Python 写 Robot Framework 测试
			
Robot Framework 框架是基于 Python 语言开发的,所以,它本质上是 Python 的一个库. 1.你懂 Python 语言. 2.又想使用 Robot Framework 测试框架 ...
 - 【jquery+easyUI】-- $.messager.show 弹框显示
			
三种基本弹框 1.提示框,一秒停留 $.messager.show({ title: '提示', msg: '修改成功!', showType: 'fade', //设置显示类型 style: { l ...
 - 好像leeceode题目我的博客太长了,需要重新建立一个. leecode刷题第二个
			
376. Wiggle Subsequence 自己没想出来,看了别人的分析. 主要是要分析出升序降序只跟临近的2个决定.虽然直觉上不是这样. 455. 分发饼干 ...
 - 2017/2/6:在oracle中varchar与varchar2的区别与增删改查
			
1.varchar2把所有字符都占两字节处理(一般情况下),varchar只对汉字和全角等字符占两字节,数字,英文字符等都是一个字节:2.VARCHAR2把空串等同于null处理,而varchar仍按 ...
 - hdu 2588(简单的欧拉
			
题意:给你一个n,m问你1-n里面(x)有多少对gcd(x, n)>=m. 思路:我们可以设n=a*b, x=a*c,此时我们可以知道b,c是互质的,那么就可以用欧拉来求解 /* gyt Liv ...