The Smart KK
Time limit: +Ms | Memory Limit:65535Kb
-
-
Describe
-
The smart "KK"
The design of an African pavilion is inspired by the undulating dunes of the legendary desert, reflecting the changing and colourful nature and urban landscape of the country. The pavilion is made up of five parts, and the in-house cinema plays a widescreen short film called "Blink of an instant", reflecting the astonishing changes in people's living standards and urban living environment since the founding of the PRC.
The movable "Dune" is inspired by its unique and majestic natural landscape-the legendary rugged dunes. The magnificent structure, recyclable building materials, and nature complement each other. Around the week, it was discovered that it was inspired by the constantly changing shape of the dunes. Realistic to the point of view from any angle, can clearly identify the characteristics of the dunes.
It "slopes" up to 20 meters, the breeze blowing, do you feel the flow of sand? Hand to touch, but found that the original is a "magic trick." The surface of the stainless steel panel presents a variety of colors, from different angles to show different colors, thus imitating the light of the flowing sand dunes.
Into the third showroom there is an oversized screen, with marvelous effects that make the audience feel like they have come to the vast desert. What is even more fascinating is that a small animal, "KK", is moving from the upper left corner of the desert area (the rectangle) down to the right and down. KK is so smart that it can choose to eat as many worm lines as possible during the run.
Do you know how many worms it eats?
-
-
Input
-
-
First line: N M (1≤n m≤20 0≤xij≤500 (i=1,2?). N, J=1,2?,m)
) means that the desert is a n*m rectangular area.
Next there are N rows: Each line has m positive integers, Xi1 Xi2 ... Xim indicates the number of insects in each location (separated by a single space)
Assume that "KK" can only go right or down.
-
-
Output
-
The
-
output has an integer that says "KK" eats the largest number of bugs.
-
-
Sample input
-
-
3 43 1 2 85 3 4 61 0 2 3
-
-
Sample output
-
-
24
-
-
Source
-
The
-
third Henan Province Program design Competition
-
-
Uploaded by
-
-
Miao-dong Building
-
-
Idea: This question has been seen before, just do not know how to find the biggest to eat the number of insects. Read the following Baidu Library write, benefited from.
-
-
is to construct a sum array, in which each element is stored in relative terms to eat the largest number of insects, I think so.
-
-
Of course, it is possible to take the biggest insect-eating route out of the way. Write a sign on the line.
-
-
Reference Library: Http://wenku.baidu.com/link?url= Hy9ujzvyxfwzuxcfykfekzuihynamdjekcuqbyxgnmbu0ngukfjilrcckk5xsn63cay56lsbvrogyxop-a-h1oxq3d8mczne7mgynecizuw
-
-
#include <iostream> #include <string.h>using namespace Std;int main () {int n,m,i,j,a[20][20],sum[20][20]; memset (sum,0,sizeof (sum)); Cin>>n>>m;for (i=0;i<n;i++) for (j=0;j<m;j++) cin>>a[i][j];sum[0 ][0]=A[0][0]; for (i=1;i<n;i++) sum[i][0]=sum[i-1][0]+a[i][0];for (i=1;i<m;i++) sum[0][i]=sum[0][i-1]+a[0][i]; for (i=1;i<n;i++) {for (j=1;j<m;j++) {if (sum[i-1][j]<sum[i][j-1]) Sum[i][j]=a[i][j]+sum[i][j-1];else SUM[I][J]=A[I][J]+SUM[I-1][J];}} Cout<<sum[n-1][m-1]<<endl;return 0;}
The Smart KK