当前位置:网站首页>1015. picking flowers
1015. picking flowers
2022-06-28 13:20:00 【HHppGo】
subject :
Hello Kitty I want to pick some peanuts for her favorite Mickey Mouse .
She came to a rectangular peanut field with a grid of roads ( Here's the picture ), Go in from the northwest corner , Come out from the southeast corner .
There is a peanut seedling growing at the intersection of every road in the field , There are some peanuts on it , After a peanut seedling, you can pick all the peanuts on it .
Hello Kitty You can only go east or South , You can't go west or North .
ask Hello Kitty How many peanuts can you pick at most .
Input format :
The first line is an integer T, Represents how many sets of data there are .
Next is T Group data .
The first row of each set of data is two integers , They represent the rows of peanut seedlings R And number of columns C.
Next for each group of data R Row data , Describe each row of peanut seedlings from north to south . Each row of data has C It's an integer , The number of peanuts per plant in the row is described from west to East M.
Output format :
Enter data for each group , Output one line , The content is Hello Kitty The number of peanuts that can be picked the most .
Data range :

sample input :
2
2 2
1 1
3 4
2 3
2 3 4
1 6 5
sample output :
8
16
Ideas :

AC Code :
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
const int N = 110;
int n,m;
int w[N][N];
int f[N][N];
int t;
int main()
{
scanf("%d",&t);
while(t--)
{
scanf("%d%d",&n,&m);
for(int i = 1;i<=n;i++)
for(int j = 1;j<=m;j++)
{
scanf("%d",&w[i][j]);
}
for(int i = 1;i<=n;i++)
for(int j = 1;j<=m;j++)
{
f[i][j] = max(f[i-1][j],f[i][j-1]) + w[i][j];
}
printf("%d\n",f[n][m]);
}
return 0;
}
边栏推荐
- 专业英语历年题
- redis和mysql数据不一致问题如何解决?
- 股票网上开户及开户流程怎样?手机开户是安全么?
- Hubble数据库x某股份制商业银行:冠字号码管理系统升级,让每一张人民币都有 “身份证”
- mysql数据库扫盲,你真的知道什么是数据库嘛
- ShareIt has outstanding strength and landed in the top 7 of the global IAP strength list
- How to find opportunities in a bear market?
- Elastic box auto wrap demo
- G1垃圾收集器中重要的配置参数及其默认值
- Forecast and Analysis on market scale and development trend of China's operation and maintenance security products in 2022
猜你喜欢

The $980000 SaaS project failed

Mobile web training -flex layout test question 1

flex布局中的align-content属性

从pdb源码到frame帧对象

在线JSON转PlainText工具
![Buuctf:[wustctf2020] plain](/img/0f/a7973d3f7593f2464e48609e27d7bd.png)
Buuctf:[wustctf2020] plain

Vs2012 VC creates a new blank window application

StackOverflow 2022数据库年度调查

Flutter series part: detailed explanation of GridView layout commonly used in flutter

一文抄 10 篇!韩国发表的顶级会议论文被曝抄袭,第一作者是“原罪”?
随机推荐
Shareit a une force exceptionnelle et se connecte au top 7 de la liste mondiale des forces IAP
Centos7: switch MySQL users and log in to MySQL
How to solve the data inconsistency between redis and MySQL?
scratch旅行相册 电子学会图形化编程scratch等级考试一级真题和答案解析2022年6月
Deep understanding of Bayes theorem
From jsonpath and XPath to spl
Customize MySQL connection pool
为什么越来越多的用户放弃 Swagger,选择Apifox
Realization of a springboard machine
Watermaker of the Flink core
5A synchronous rectifier chip 20V to 12v2a/5v4.5a high current 24W high power synchronous rectifier chip high current step-down IC fs2462
电子元器件分销10亿俱乐部[通俗易懂]
Embedded development: seven techniques for estimating battery life
Google Earth engine (GEE) - Global organic soil area of FAO (1992-2018)
数据分析-启动子进化分析
Why do more and more users give up swagger and choose apifox
go template with... End traversal usage
4年用户数破亿,孙哥带领波场再创新高
Hubble数据库x某股份制商业银行:冠字号码管理系统升级,让每一张人民币都有 “身份证”
STM32F1与STM32CubeIDE编程实例-矩阵键盘驱动