Smart "KK" (the third provincial race)

Source: Internet
Author: User

The smart "KK"

(The code is not very long this problem is written by teammates, the idea is: Read into each number in the position of the number to deposit from the beginning to the point of the maximum value , the bottom right corner of the value is the result)

The design of a national pavilion in Africa 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?

Enter the first line: N M indicates that the desert is a n*m rectangular region followed by n rows: Each line has M positive integers, Xi1 Xi2 ... Xim indicates the number of insects in each location (separated by a single space)

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
Tips

1≤n m≤20 0≤xij≤500 (i=1,2 ". N, j=1,2 ", M)


Assume that "KK" can only go right or down.

1#include <stdio.h>2#include <string.h>3 #defineN 304 #defineMax (A, B) (a > B? a:b)5 intDp[n][n];6 intMain ()7 {8     intm, N, I, J, X;9      while(SCANF ("%d%d", &m, &n)! =EOF)Ten     { OneMemset (DP,0,sizeof(DP)); A          for(i =0; I < m; i++) -         { -              for(j =0; J < N; J + +) the             { -scanf"%d", &dp[i][j]); -                 if(i==0&&j!=0) -DP[I][J] + = dp[i][j-1]; +                 Else if(j==0&&i!=0) -DP[I][J] + = dp[i-1][j]; +                 Else ADP[I][J] + = max (dp[i-1][j],dp[i][j-1]); at             } -         } -printf"%d\n", dp[i-1][j-1]); -     } -     return 0; -}

Smart "KK" (the third provincial race)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.