Eating Peach (peach)
Description
On this day, the little monkey went looking for food. He came to a rectangular peach garden with grid-like roads (as shown in the picture below), entered from the northwest corner and exited from the southeast corner. There is a peach tree planted at every intersection of roads in the field, with several peaches on it, and all the peaches on it are picked after passing a peach tree. The little monkey can only go east or south, not west or north. Q: How many peaches can the little monkey pick at most?
Format
Input
The first line is an integer \(T (1 \leq T \leq 70)\), which represents how many sets of data there are.
Next is the \(T\) group data. The first row of each group of data is two integers, representing the number of rows \(R\) and the number of columns \(C\) of the peach tree (\(1 \leq R, C<100\)).
The next \(R\) rows of data in each set of data describe the situation of each row of peach trees in turn from north to south.
Each row of data has C integers, describing the number of peaches \(M\) on each peach tree in the row in order from west to east (\(0 \leq M<1000\)).
Output
For each group of input data, output one line, the content is the number of peaches that the monkey can pick the most.
Sample1
Input
2
2 2
1 1
3 4
2 3
2 3 4
1 6 5
Output
8
16
Sample Code
#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
int t,r,c;
int a[105][105];
int main() {
freopen("peach.in","r",stdin);
freopen("peach.out","w",stdout);
cin>>t;
while(t--) {
cin>>r>>c;
for(int i=1; i<=r; i++) {
for(int j=1; j<=c; j++) {
cin>>a[i][j];
}
}
for(int i=1; i<=r; i++) {
for(int j=1; j<=c; j++) {
a[i][j]+=max(a[i-1][j],a[i][j-1]);//At this time, use the backward method. Because there are only two directions to get to this point:
}
}
cout<<a[r][c]<<endl;//One is on the left and the other is on the top. The point where the accumulated number is larger is from which point.
}
return 0;
}
Eating Peach (peach)的更多相关文章
- Peach+Fuzzer
目录 1 Peach是什么....................................................................................... ...
- 东大OJ-1544: GG的战争法则
题目描述 你在桥上看风景 看风景的人在楼上看你 明月装饰了你的窗子 你装饰了我的梦 这是GG在长坂坡发出的感叹. 三年前GG莫名的穿越到了三国时期,在这三年里他看尽了各种杀戮,心里早已麻木.GG他渴望 ...
- Java基础算法集50题
最近因为要准备实习,还有一个蓝桥杯的编程比赛,所以准备加强一下算法这块,然后百度了一下java基础算法,看到的都是那50套题,那就花了差不多三个晚自习的时间吧,大体看了一遍,做了其中的27道题,有一些 ...
- go编程之常见工具函数
1.时间格式化 基于模式的布局进行时间格式化和解析 package main import "fmt" import "time" func main() { ...
- 【JavaScript for循环实例】
1.大马驮2石粮食,中马驮1石粮食,两头小马驮一石粮食,要用100匹马,驮100石粮食,该如何调配? //驮100石粮食,大马需要50匹 for(var a=0;a<=50;a++){ //驮1 ...
- JS for循环 if判断、white循环。小练习二
假设一个简单的ATM机的取款过程是这样的:首先提示用户输入密码(password),最多只能输入三次,超过3次则提示用户“密码错误,请取卡”结束交易.如果用户密码正确,再提示用户输入取款金额(amou ...
- Java8分组(groupingBy)
1.分组,计数,排序 public class Java8Example1 { public static void main(String[] args) { List<String> ...
- Pronunciation Guide for 25 Common Fruits
Pronunciation Guide for 25 Common Fruits Share Tweet Share Tagged With: Vocabulary Words Know how to ...
- ref:一系列用于Fuzzing学习的资源汇总
ref:http://www.freebuf.com/articles/rookie/169413.html 一系列用于Fuzzing学习的资源汇总 secist2018-04-30共185833人围 ...
随机推荐
- hdu6704 2019CCPC网络选拔赛1003 K-th occurrence 后缀自动机+线段树合并
解题思路: fail树上用权值线段树合并求right/endpos集合,再用倍增找到待查询串对应节点,然后权值线段树求第k大. #include<bits/stdc++.h> using ...
- WPF实现手势解锁
桌面程序的解锁方式一般是账号密码,互联网的可以使用扫码解锁,甚至人脸识别.但扫码需要网络,人脸识别又较复杂.所以就想把安卓常用的手势解锁移植到桌面程序上. 先来张效果图,有兴趣的往下看,没兴趣的打扰了 ...
- 阿里云短信服务验证码封装类 - PHP
本文记录在ThinkPHP6.0中使用阿里云短信验证码,该封装类不仅仅局限于TP,拿来即用 使用该类之前必须引入 flc/dysms 扩展,该封装类就是基于这个扩展写的 composer requir ...
- Tomcat配置SSL
Tomcat配置SSL 查询网上资料配置如下: <Connector port="8443" protocol="HTTP/1.1" maxThreads ...
- selenium+python对表格数据的操作
一.直接获取整个表格数据,包含表头 def table_info(self): tr_data=[] table_data=[] css='id=>useradmin'#根据表格id找到表格 s ...
- vue父子组件状态同步的最佳方式续章(v-model篇)
大家好!我是木瓜太香!一名前端工程师,之前写过一篇<vue父子组件状态同步的最佳方式>,这篇文章描述了大多数情况下的父子组件同步的最佳方式,也是被开源中国官方推荐了,在这里表示感谢! 这次 ...
- Spring Boot 所有相关的配置信息
加载顺序 如上图所示,图片是从官网上截取的,这些配置信息都会加载,只不过顺序在前的会覆盖掉后面的 上图的所有配置信息都会以(key,value)的形式加载到Spring中的Environment中,也 ...
- maximo----对比竞品的优势,以及sp的优势
众多资产密集型企业对eam产品关注度都很高,尤其是eam产品的功能差别,这与行业差别有直接关系,如电力行业.煤炭行业或石油行业等,各行有各行的运营特点,那么eam产品在共性的基础上定出存在细小差异.下 ...
- python 第二节课内容和练习
一.列表 []表示列表,用','进行分隔,list有序 能够进行索引 切片 (in append extend count index insert pop remove,reverse sort c ...
- windows服务器添加磁盘后,提示The disk is offline because of policy set by an administrator的解决办法
操作系统:Windows Server 2008 R2 Enterprise 事件:存储在虚拟机上添加三块磁盘,笔者准备扩展到E盘(动态分区) 问题:存储团队添加磁盘后,OS的磁盘管理界面,看到提示, ...