Problem F
Sneaky Snowninjas

The honourable ninja Hattori Hanzō has just conducted a successful assassination of one of the greatest enemies of his clan and needs to make sneaky getaway. Unfortunately for him, it has snowed recently and he needs to be careful not to leave any prints in the snow to avoid being tracked. He comes up with the brilliant plan of only stepping in the old footprints that already exist in the snow, so that his enemies can’t track him by his very distinctive shoe tracks (in hindsight, it was a mistake to get custom made shoes with the print “Hattori Hanzō” on the bottom).
Hattori Hanzō starts at coordinate
Input
The first line of the input consist of a single integer
Each of the following
The limits on the input are:
-
-
-
-
-
The sum of all values of
is at most .
Output
For each test case, output the furthest distance (as the bird flies) the ninja can get from his starting point, rounded down to the nearest integer. Output this distance in centimeters.
Sample Input 1 | Sample Output 1 |
---|---|
1 5 50 50 50 150 150 50 225 50 50 240 |
245 |