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 |