
You live in a neighbourhood which is arranged as a straight line.
Your pet Fax is very popular among the
Initially, your Fax is lazy and unable to move, but when he consumes sugar, he becomes hyper and begins to run.
The
You are the first neighbour, and you are located at
What is the maximum distance that your Fax can travel while hyper?
Input Specification
The first line will contain
For each of the next
No two neighbours share the same
- For 2 of the 15 available marks,
. - For an additional 3 of the 15 available marks,
. - For an additional 3 of the 15 available marks,
. - For an additional 3 of the 15 available marks,
.
Output Specification
Output one integer, which is the maximum total distance that your Fax can travel while hyper.
Sample Input 1
2
0 10
-10 10
Sample Output 1
20
Sample Input 2
2
0 10
11 10
Sample Output 2
10
Sample Input 3
3
0 2
1 2
-1 2
Sample Output 3
6
Comments
Does the sugar carry on from neighbour to neighbour? So if not all sugar is used from one neighbour to next, does it carry on?
Yes, all of the previous sugar can still be used up.