当前位置:网站首页>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;
}
边栏推荐
- 股票网上开户及开户流程怎样?手机开户是安全么?
- From jsonpath and XPath to spl
- You must configure either the server or JDBC driver (via the ‘serverTimezone‘ configuration property
- StackOverflow 2022数据库年度调查
- Complete backpack beginner chapter "suggestions collection"
- 从pdb源码到frame帧对象
- How to handle the safest account opening when downloading the mobile app of Huatai Securities
- Scratch travel photo album Electronic Society graphical programming scratch grade examination level 1 true questions and answers analysis June 2022
- Après avoir échoué à l'examen d'entrée à l'Université de technologie de Harbin, vous devez rester à l'Université en tant que « chercheur » après avoir obtenu votre diplôme.
- Tiantian mathematics serial 53: February 22
猜你喜欢
Align content attribute in flex layout
How to find opportunities in a bear market?
In the past four years, the number of users exceeded 100 million, and sun Ge led the wave field to a new high
pytorch基础
中二青年付杰的逆袭故事:从二本生到 ICLR 杰出论文奖,我用了20年
PHP抓取网页获取特定信息
Here comes Wi Fi 7. How strong is it?
Solution to directory access of thinkphp6 multi-level controller
Mysq 8.0 launched histogram, which greatly improved the performance!
pytorch模型
随机推荐
Fh511+tp4333 form an outdoor mobile power lighting camping lamp scheme.
从pdb源码到frame帧对象
Hisilicon 35xx realizes gt911 touch screen function "suggestions collection"
Vs2012 VC creates a new blank window application
Google Earth engine (GEE) - Global organic soil area of FAO (1992-2018)
Matlab plotyy coordinate axis setting, [reprint] example of MATLAB plotyy drawing double ordinate graph [easy to understand]
泛海微FH511单片机IC方案小家电LED照明MCU丝印FH511
flex布局中的align-content属性
Setup and upload of arduino-esp32 flash file plug-in program
Here comes Wi Fi 7. How strong is it?
Which company has a low rate for opening a securities account? How to open an account is the safest
From jsonpath and XPath to spl
I ² C. SMBus, pmbus relationships
电驴怎么显示服务器列表,(转)如何更新电驴服务器列表(eMule Server List)
哈希竞猜游戏系统开发技术成熟案例及源码
Stackoverflow 2022 database annual survey
PHP obtains the beginning and end time of the month according to the month and year
电脑无线网络不显示网络列表应该如何解决
Microservice stability guarantee
The difference between align items and align content