Alice loves webbing through the forest, but has never been bitten by a radioactive spider, so she has decided to buy a grappling hook from the dollar store, which turns out to be very inconsistent.
The forest has $$$N$$$ trees, each a vertical line represented by two points: $$$x_i$$$ and $$$y_i$$$ from ($$$x_i, 0$$$) to ($$$x_i, y_i$$$), where all $$$x_i$$$ are distinct and all $$$y_i$$$ are distinct.
Alice's purpose is to grapple from treetop to treetop from left to right and to maximize the total area under her (she really loves being high up in the sky). When grappling between two treetops, she may not pass through any other tree, including the very top. However, her grappling hook might malfunction, but only when she is on a point on the original optimal path.
You are also given a number $$$K$$$, which is either $$$1$$$ or $$$2$$$. If $$$K = 1$$$, find the maximum area if the optimal path is taken with no errors. If $$$K = 2$$$, find the area if the optimal path is taken, but whenever Alice is at a point on the original optimal path, the grappling hook misses in the worst way possible for the total area (if there is no way to miss, e.g. the next point is also in the original optimal path, the grappling hook will work normally).
Line $$$1$$$: Two space separated integers $$$N$$$ ($$$1 \le N \le 2 \times 10^5$$$)and $$$K$$$ ($$$1 \le K \le 2$$$).
Lines $$$2…N+1$$$: Two integers, $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le 10^9$$$), denoting the x and y coordinates of the $$$i$$$th tree.
Line $$$1$$$: One integer representing either the optimal area or the area in the case of the worst possible misses, if $$$K = 1$$$ or $$$2$$$, respectively. Instead of printing out the raw answer, print out $$$(2 \times answer)$$$, which is guaranteed to be an integer.
5 2 1 11 2 8 3 7 4 9 5 13
76