当前位置:网站首页>-Pickling peanuts-
-Pickling peanuts-
2022-08-10 01:48:00 【-JMY-】
Title description
When participating in the "Peanut Picking" competition, the examiner will present a peanut field with n rows and m columns, on which a total of n*m peanut seedlings are planted.Each peanut plant bears a certain number of peanut fruits. At the beginning of the competition, the contestants stand in the 1st row and the 1st column. Now it is required to find the peanut plant with the most peanut fruits in the shortest time (data guarantee peanutsThere is only one plant with the most fruit), and then go south (down) and then east (right) to pick its peanuts, and pick the peanuts under other peanut plants that pass along the way.Come down, but not allowed to pick peanut plants that have not passed by, otherwise it will be dealt with as a foul.How many peanuts can this player pick in total?
Such as a peanut field with n=5, m=6
1st column 2nd column 3rd column 4th column 5th column 6th column
1st row 5 5 4 7 5 13
Line 2 9 6 3 2 8 7> Line 3 10 14 0 1 9 4
Line 4 6 9 18 25 0
Ring 5 3 1 2 9 0 2
Yes, yes you canIf the peanut plant with the most peanuts is found at (4, 5), the order of picking should be (1, 1)-(2, 1)-(3, 1)-(4, 1)-(4, 2)-(4,3)-(4,4)-(4,5), the total number of peanuts picked is 5+9+10+4+6+9+18+25=86.
Enter
The first row has two integers n and m ( 1 < n,m <= 100 ), which means that the peanut field has n rows and m columns.
Lines 2 to n+1, each line has m integers separated by spaces, the jth integer Pij (0 <= Pij <= 700) in line i + 1 represents the plants in the peanut field (i, j) The number of peanuts under the plant, 0 means there is no peanut under the plant.
Output
There is only one line, an integer, indicating the total number of peanuts picked by the contestants.
Sample input
5 65 7 4 5 1 139 6 3 2 8 710 14 0 1 9 44 6 9 18 25 03 1 2 9 0 2
Sample output
86
Reference code:
#include
using namespace std;
int n,m,a[105][105],x,y,s,maxn;
int main(){
scanf("%d%d",&n,&m);
for(int i=0;i
for(int i=0;i
maxn=a[i][j];
x=j+1;
y=i+1;
}
for(int i=0;i
for(int i=1;i
printf("%d",s);
return 0;
}
边栏推荐
- win10重装系统后没声音怎么办?
- How to activate the payment function on WeChat official account?
- Are the numbers entered symmetrical?
- 基于 LSTM 的分布式能源发电预测(Matlab代码实现)
- 渗透测试与攻防对抗——漏洞扫描&逻辑漏洞(Part1)
- [NCTF2019]True XML cookbook-1|XXE漏洞
- [obs] obsqsv11 hard coding and comparison with metartc codec
- Leecode-205. 同构字符串
- 02| operator
- Leetcode83. 删除排序链表中的重复元素
猜你喜欢
随机推荐
c语言文件基本操作总结
数据的存储——C语言
Why don't suggest you run in Docker Mysql?
深入理解Aarch64内存管理
CAS:851113-28-5 (Biotin-ahx-ahx-tyramine)
WPF DataGrid using data templates
02| operator
程序员从佩洛西窜访事件中可以学到什么?
CST Studio Suite 2021 software installation package and installation tutorial
Next.js获取路由参数及styled-jsx 的使用
西安生物素-四聚乙二醇-酰胺-4苯酚 浅黄色半固态
地雷数量求解
Redis 非关系型数据库学习(一) ---- Redis 的安装
-采花生-
Kubernetes 60个为什么
大龄测试员刚迈过了 35 岁这个“坎儿”,和大家说点儿心里话
abicc 知:API compatibility report 介绍
【C语言】通讯录《静态内存版本》
MATLB|And her ups and downs and finally reached the peak of life [Romantic Journey]
基于FPGA的任意字节数的串口接收(含源码工程)
![[C language] Address book](/img/56/a72900c22b965947ee88256d8f6c21.jpg)








