F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

CS and Sugar

Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65768/32768 K (Java/Others)
Total Submission(s): 511    Accepted Submission(s): 208


Problem Description
CS and Sugar find a new continent at the same time. Rare plants are all over this miraculous land, so they decided to take them home and sell it. But obviously, not all plants can be sold at a good price. Some plants are just usual weed. After some time of observation, they became self-taught botanists. CS and Sugar divided a rectangle area into n*m grids, and marked them with different values (maybe negative). They dig in turns to be fare, when all the plants in a grid are taken by the last person, and next person start to move on. The next person always chooses the one of the grids which are above and left to the last person, including the straight above or straight left. And even that, CS and Sugar still tried to compete with each other, and they always choose the available part with higher absolute value than last one no matter positive or negative. The first person can choose any grid to begin. Until someone is not able to make any move, they left. They are now debating who should dig first because they have already calculated how many advantages the first person can get.
 

Input
Multiple test cases (no more than 100), for each case:
The first line contains two integers n and m (0<n, m<=100), representing the rectangle area was divided into n*m parts.
Following n lines, each line contains m integers whose absolute value is no more than 100, representing the value in each part.
 

Output
For each case, output one integer, representing the maximum advantage the first person can get in total value.
 

Sample Input
1 5 -5 -4 -3 -2 -1 2 2 -7 -6 -6 5 3 2 -6 -5 -4 -4 2 4
 

Sample Output
1 4 3
 

Author
zyue1105
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 04:28:33, Gzip enabled