문제
Bessie's younger cousins, Ella and Bella, are visiting the farm. Unfortunately, they have been causing nothing but mischief since they arrived.
In their latest scheme, they have decided to mow as much grass as they can. The farm's prime grassland is in the shape of large
Ella and Bella plan to both start at
Bessie is rather concerned that too much grass will be cut, so she invents a clever plan to constrain the paths Ella and Bella take. There are
Ella and Bella will try to maximize the amount of grass they cut, subject to the restriction of visiting flowers in
Problem credits: Dhruv Rohatgi
입력
The first line contains
In at least 20% of the test cases, it is further guaranteed that
출력
A single integer, giving the minimum possible amount of cut grass.
예제1
5 20
19 1
2 6
9 15
10 3
13 11
117
In the above example, it is optimal for Bessie to pick the flowers at