HdU 2391-Filthy Rich
来源:互联网 发布:steam网络无法连接 编辑:程序博客网 时间:2024/06/06 05:45
Filthy Rich
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3756 Accepted Submission(s): 1662
题目链接:点击打开链接
Problem Description
They say that in Phrygia, the streets are paved with gold. You’re currently on vacation in Phrygia, and to your astonishment you discover that this is to be taken literally: small heaps of gold are distributed throughout the city. On a certain day, the Phrygians even allow all the tourists to collect as much gold as they can in a limited rectangular area. As it happens, this day is tomorrow, and you decide to become filthy rich on this day. All the other tourists decided the same however, so it’s going to get crowded. Thus, you only have one chance to cross the field. What is the best way to do so?
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.
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.
Input
The input starts with a line containing a single integer, the number of test cases.
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.
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.
Output
For each test case, write a line containing “Scenario #i:”, where i is the number of the test case, followed by a line containing the maximum amount of gold you can collect in this test case. Finish each test case with an empty line.
Sample Input
13 41 10 8 80 0 1 80 27 0 4
Sample Output
Scenario #1:42
题意:
给你一个矩阵,每个位置都有一个非负数,现在你在左上角,让你求当你走到右下角的时候,能得到的最大数的总和。
分析:
和矩阵取数的题很像,但是比那还要简单,因为不存在负数,直接可以再输入的时候更新我们所想要的每个位置的最大值,我理解的最后一句话是可以从左上角走到右下角能得到最大的数,可以向下走向右走,向右下走,我滴天,竟然不是,只能向下向右走,是我理解有误吗?
#include <iostream>#include<stdio.h>#include<math.h>#include<string>#include<string.h>using namespace std;int map1[1005][1005];int main(){ int t,r,c,bj=0; scanf("%d",&t); while(t--) { scanf("%d %d",&r,&c); for(int i=1;i<=r;i++) { for(int j=1;j<=c;j++) { scanf("%d",&map1[i][j]); map1[i][j]+=max(map1[i-1][j],map1[i][j-1]); } } printf("Scenario #%d:\n",++bj); printf("%d\n",map1[r][c]); printf("\n"); } return 0;}
阅读全文
0 0
- hdu 2391 Filthy Rich
- hdu 2391 Filthy Rich
- hdu 2391 Filthy Rich
- hdu 2391 Filthy Rich
- HDU 2391 Filthy Rich
- hdu 2391 Filthy Rich
- hdu 2391 Filthy Rich
- hdu 2391 Filthy Rich
- HDU 2391 Filthy Rich
- HDU 2391 Filthy Rich
- hdu 2391 filthy rich
- hdu 2391 Filthy Rich
- HDU 2391 Filthy Rich
- HdU 2391-Filthy Rich
- HDU 2391--Filthy Rich【数塔】
- HDU 2391 Filthy Rich (滚动dp)
- HDU 2391 Filthy Rich (简单DP)
- HDU 2391 Filthy Rich(dp)
- hibernate深度学习 游离状态 HQL
- 订餐系统路径问题
- winform-wpf-窗体混合显示
- 在web开发中使用iconfont字体图标
- 微信扫码支付
- HdU 2391-Filthy Rich
- 制作HTML5游戏
- windows建立共享文件夹并用Ubuntu系统访问
- 网易2018校园招聘:合唱 [python]
- 判断能否构成三角形(异常处理)
- Construct 2再次探索
- Java 异常处理的误区和经验总结
- poj1088 滑雪
- 1、在qt下创建slam项目-hello slam