当前位置:网站首页>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;
}
边栏推荐
- fastposter v2.8.4 发布 电商海报生成器
- Centos7: switch MySQL users and log in to MySQL
- An idea plug-in that automatically generates unit tests, which improves the development efficiency by more than 70%!
- Google Earth engine (GEE) - Global organic soil area of FAO (1992-2018)
- Hubble数据库x某股份制商业银行:冠字号码管理系统升级,让每一张人民币都有 “身份证”
- Writing skills of resume
- FS7022方案系列FS4059A双节两节锂电池串联充电IC和保护IC
- Arduino-ESP32闪存文件插件程序搭建和上传
- 5A同步整流芯片 20V转12V2A/5V4.5A大电流 24W大功率同步整流芯片 大电流降压IC FS2462
- 同花顺上怎么进行开户啊, 安全吗
猜你喜欢

Successful cases of rights protection of open source projects: successful rights protection of SPuG open source operation and maintenance platform

Online JSON to plaintext tool

Writing skills of resume

嵌入式开发:估算电池寿命的7个技巧

词云的可视化设计教程

flex布局中的align-content属性

Solution to directory access of thinkphp6 multi-level controller

Hubble database x a joint-stock commercial bank: upgrade the number management system of Guanzi, so that every RMB has an "ID card"

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.

ShareIt has outstanding strength and landed in the top 7 of the global IAP strength list
随机推荐
电子元器件分销10亿俱乐部[通俗易懂]
China Database Technology Conference (DTCC) specially invited experts from Kelan sundb database to share
ShareIt has outstanding strength and landed in the top 7 of the global IAP strength list
Centos6.5 php+mysql MySQL library not found
How to display the server list of the electric donkey, and how to update the eMule server list
SHAREit实力出众,登陆全球 IAP 实力榜 Top7
如何在熊市中寻找机会?
2. 01背包问题
开源项目维权成功案例: Spug 开源运维平台成功维权
Writing skills of resume
MySQL多表联合查询
投资98万美元的Saas项目失败了
895. 最长上升子序列
弹性盒子自动换行小Demo
Copy 10 for one article! The top conference papers published in South Korea were exposed to be plagiarized, and the first author was "original sin"?
Customize MySQL connection pool
腾讯汤道生:面向数实融合新世界,开发者是最重要的“建筑师”
数启扬帆,智聚人才 | 腾讯云数据库 & CSDN 工程师能力轻量认证发布会重磅来袭!...
PHP根据年月获取月初月末时间
Forecast and Analysis on market scale and development trend of China's operation and maintenance security products in 2022