当前位置:网站首页>-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;
}
边栏推荐
猜你喜欢
随机推荐
-骑士巡游-
Creo5.0 introductory tutorial free material
Mysql数据库 ALTER 基本操作
Koa中间件next实现
Tensor flow 踩坑记
数据的存储——C语言
生物素叠氮化物中的(CAS:1527486-16-3TAMRA-azide-PEG3-Biotin)反应的特点!
02| operator
Leetcode83. 删除排序链表中的重复元素
微服务【同步和异步通讯详解】第6章
dlopen failed: library "libtaml.so" not found
由生物素参与的D-Biotinol,CAS号:53906-36-8具体特性说明
labelme标注的json标签转txt格式
Biotin-Cy2 Conjugate,生物素-Cy2 偶联物_Cy2 生物素偶联物
【CAS:41994-02-9 |Biotinyl tyramide】生物素基酪氨酰胺价格
-Chess game-
程序员从佩洛西窜访事件中可以学到什么?
PEG 衍生物Biotin-PEG1-OH(cas:95611-10-2,2-生物素氨基乙醇)优势说明
Docker interview question 2--get the number of database connections and docker-compose
重估HR SaaS:一体化后的新三年