hdu_2391 Filthy Rich DP
Filthy Rich
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 4393 Accepted Submission(s): 1898
Given a rectangular map and amounts of gold on every field, determine the maximum amount of gold you can collect when starting in the upper left corner of the map and moving to the adjacent field in the east, south, or south-east in each step, until you end up in the lower right corner.
Each test case starts with a line, containing the two integers r and c, separated by a space (1 <= r, c <= 1000). This line is followed by r rows, each containing c many integers, separated by a space. These integers tell you how much gold is on each field. The amount of gold never negative.
The maximum amount of gold will always fit in an int.
一道dp题, 从左上角走到右下角,只能往右、下或右下走,求捡到的金子最多为多少。
#include <iostream>
#include <stdio.h>
#include <string.h> using namespace std; int dp[][]; int Max(int a, int b)
{
return a>b? a:b;
} int main()
{
int t, r, c;
scanf("%d", &t);
for(int i=; i<; i++)
{
dp[i][]=;
dp[][i]=;
}
for(int k=; k<t; k++)
{
scanf("%d%d", &r, &c); for(int i=; i<=r; i++)
for(int j=; j<=c; j++)
{
scanf("%d", &dp[i][j]);
dp[i][j] += Max(dp[i-][j], dp[i][j-]);
}
printf("Scenario #%d:\n", k+);
printf("%d\n\n", dp[r][c]);
} return ;
}
hdu_2391 Filthy Rich DP的更多相关文章
- HDU 2391 Filthy Rich (dp)
题目连接 Problem Description They say that in Phrygia, the streets are paved with gold. You're currently ...
- hdu 2391 Filthy Rich
单纯dp 水一 处理时间点,第一行和第一列特殊处理: 其余的w[i][j]=show(w[i-1][j-1],w[i-1][j],w[i][j-1]); <span style="fo ...
- (转) [it-ebooks]电子书列表
[it-ebooks]电子书列表 [2014]: Learning Objective-C by Developing iPhone Games || Leverage Xcode and Obj ...
- JAVA 画图机制
java学习脚印:深入java绘图机制 写在前面 封装性越好的类在使用时,只要清楚接口即可,而不应该让程序员了解其内部结构; 对于平常的绘图来讲,java绘图机制无需了解太多,但是朦胧容易产生错误,绘 ...
- ACM: 强化训练-Beautiful People-最长递增子序列变形-DP
199. Beautiful People time limit per test: 0.25 sec. memory limit per test: 65536 KB input: standard ...
- hdu--(1025)Constructing Roads In JGShining's Kingdom(dp/LIS+二分)
Constructing Roads In JGShining's Kingdom Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65 ...
- 你有PSD的学位吗? - dp的日志 - 网易博客
你有PSD的学位吗? - dp的日志 - 网易博客 你有PSD的学位吗? 2011-08-01 12:58:40| 分类: 感悟 | 标签:自我提升 |字号 大中小 订阅 去年, ...
- (中等) POJ 2948 Martian Mining,DP。
Description The NASA Space Center, Houston, is less than 200 miles from San Antonio, Texas (the site ...
- Humble Numbers HDU - 1058 2分dp
JGShining's kingdom consists of 2n(n is no more than 500,000) small cities which are located in two ...
随机推荐
- D - Super Jumping! Jumping! Jumping!
Nowadays, a kind of chess game called "Super Jumping! Jumping! Jumping!" is very popular i ...
- Nginx知多少系列之(三)配置文件详解
目录 1.前言 2.安装 3.配置文件详解 4.Linux下托管.NET Core项目 5.Linux下.NET Core项目负载均衡 6.Linux下.NET Core项目Nginx+Keepali ...
- python基本知识点if、while、等等
给予Python的相关知识点: 主要是对于基本语句的相关使用if else while for等先关的应用,以及步骤如下: 尝试编程如下:还有就是对于 import math import rando ...
- 第二章 IBM
1.不要招惹IBM,这可是一家做过军火的公司,一家参与了曼哈顿计划的公司. 同时也是世界上最大的服务公司.第二大软件公司.第二大数据库公司.拥有工业界最大的实验室.第一专利申请大户.最大的开源linu ...
- Date 对象-->概念、创建以及方法
1.概念: Date 对象用于处理日期与时间. 2.创建: 方法1:直接用Date()函数,返回值当前时间 格式:var d = Date(); 注意:不论Date()是否带参数,返回都是当前时间 举 ...
- java中JVM虚拟机内存模型详细说明
java中JVM虚拟机内存模型详细说明 2012-12-12 18:36:03| 分类: JAVA | 标签:java jvm 堆内存 虚拟机 |举报|字号 订阅 JVM的内部结构 ...
- JSR303完成validate校验并编写BeanValidator工具类
一.引入pom依赖 <!-- validator --> <dependency> <groupId>javax.validation</groupId> ...
- css文本阴影
文本阴影-text-shadow text-shadow 属性向文本添加一个或多个阴影.该属性是逗号分隔的阴影列表,每个阴影有两个或三个长度值和一个可选的颜色值进行规定,省略的长度是 0. h-sha ...
- harbor仓库搭建
harbor安装要求 harbor快速部署 下载harbor:https://github.com/goharbor/harbor/releases 这边以harbor-1.8.2为例 [root@g ...
- python超实用的30 个简短的代码片段(二)
Python是目前最流行的语言之一,它在数据科学.机器学习.web开发.脚本编写.自动化方面被许多人广泛使用. 它的简单和易用性造就了它如此流行的原因. 如果你正在阅读本文,那么你或多或少已经使用过P ...