Hdu 5234 Happy Birthday (BC #42 C) (DP)

Source: Internet
Author: User


Happy BirthdayTime limit:2000/1000 MS (java/others) Memory limit:65536/65536 K (java/others)
Total submission (s): 672 Accepted Submission (s): 302


Problem Descriptiontoday is Gorwin ' s birthday. So she mother want to realize her a wish. Gorwin says that she wants to eat many cakes. Thus, her mother takes she to a cake garden.

The garden was splited into n*m grids. In each grids, there is a cake. The weight of cake in the i-th row j-th column isWiJ Kilos, Gorwin starts from the Top-left (all) grid of the garden and walk to the Bottom-right (n,m) grid. In each step Gorwin can go to right or down, i.e when Gorwin stands in (i,j), then she can go to (i+1,j) or (i,j+1) (Howev Er, she can not be go out of the garden).

When Gorwin reachs a grid, she can eat up the cake in that grid or just leave it alone. However she can ' t eat part of the cake. But Gorwin's belly is not very large, so she can eat at the most K kilos cake. Now, Gorwin have stood in the Top-left grid and look at the "Map of the garden" she want to find a route which can leads her To eat most cake. But the map was so complicated. So she's wants you.
Inputmultiple test Cases, every case gives N, M, K

In the next n lines, the i-th line contains m integersWI1,WI2 , wi3< Span id= "mathjax-span-43" class= "Mo" >,? w i m Which describes the weight of cakes in the i-th row

Please process to the end of file.

[Technical specification]

All inputs is integers.

1<=n,m,k<=100

1<=WiJ<=100

Outputfor each case, output a integer in a single line indicates the maximum weight of cake gorwin can eat.
Sample INPUT1 1 232 3 1001 2 34 5 6
Sample Output016HintIn the first case, Gorwin can ' t eat part of cake, so she can ' t eat any cake. In the second case, Gorwin walks though below route (+ 2,1)--(2,2). When she passes a grid, she eats up the cake in that grid. Thus The total amount cake she eats is 1+4+5+6=16.
Sourcebestcoder Round #42
Recommendhujie | We have carefully selected several similar problems for you:5338 5337 5336 5335 5334

Hdu 5234 Happy Birthday (BC #42 C) (DP)

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.