当前位置:网站首页>-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;
}
边栏推荐
猜你喜欢
随机推荐
Kubernetes 开发环境比对
Stanford CS143 Speed Pass PA1 Tutorial
Mysql数据库 ALTER 基本操作
知行合一的时候
【「收藏」Oracle 数据库安装】
JVM Memory and Garbage Collection - 10. Direct Memory
足不出户也能看星空
[SUCTF 2019]CheckIn (.htaccess和.user.ini)
输入的这些数是否对称
Kubernetes 60个为什么
[NCTF2019]True XML cookbook-1|XXE漏洞
pytest:如何在测试中编写和报告断言
Redis 非关系型数据库学习(一) ---- Redis 的安装
线程的同步与互斥
MATLB|And her ups and downs and finally reached the peak of life [Romantic Journey]
WPF DataGrid 使用数据模板
EL表达式
365天挑战LeetCode1000题——Day 052 逐步求和得到正数的最小值 贪心
Redis redisTemplate.execute 执行锁
Docker interview question 2--get the number of database connections and docker-compose