To make some extra pocket money, Angie got a job stacking chairs!
Today, she was assigned a room to stack chairs in. The room begins with
However, her boss has a very odd method of payment - for each chair stacked, he will pay
*The Manhattan distance between points
Constraints
For all subtasks:
Subtask 1 [20%]
Subtask 2 [20%]
Subtask 3 [30%]
Subtask 4 [30%]
Input Specification
The first line contains the space separated integers
The next
Output Specification
Output one integer, the maximum amount of money she can make.
Sample Input
5 10
3 8
9 1
10 2
4 5
7 8
Sample Output
54
Explanation
Moving all the chairs to
Comments