NYOJ-171 Smart KK

Source: Internet
Author: User

the Smart KK
Time limit: Ms | Memory Limit: 65535 KB
Difficulty: 3
Describe
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 4
3 1 2 8
5 3 4 6
1 0 2 3
Sample output
24
Source
The third Henan Province Program design Competition

The simplest dynamic programming, referring to a digital triangle:

The code is as follows:

#include <iostream>#include <cstdio>#include <algorithm>#include <cstring>using namespace STD;intdp[ +][ +]={0};intMain () {intN,m;scanf("%d%d", &n,&m); for(intI=1; i<=n;i++) { for(intj=1; j<=m;j++) {scanf("%d", &dp[i][j]); Dp[i][j]+=max (dp[i-1][j],dp[i][j-1]); }    }printf("%d\n", Dp[n][m]);return 0;}

Only on behalf of personal views, welcome to Exchange discussion, do not spray ~ ~

Photoby:wlop

Http://weibo.com/wlop

NYOJ-171 Smart KK

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.