Prodo's 100-Day Preparation
Time limit2sMemory limit512 MB
Given a histogram-shaped rectilinear polygon by its vertices, find the largest-area L-shaped rectilinear polygon that can be cut from it.
- Level
Hard8 of 10
- Topics
- Array, Stack, Divide and conquer
- Solved
- No attempts yet
Problem

Prodo and Neo will soon mark 100 days together. Prodo could not bear the fallout if he did nothing on the 100th day, so he decided to prepare a small event for Neo. Everything is ready. All that remains is to cut paper into the word "LOVE". But Prodo rushed, and he wasted paper while cutting out 'O', 'V', and 'E'. What is left is a histogram-shaped rectilinear polygon like the one in Figure 1. Since it turned out this way, Prodo wants to cut out an 'L' as big as his love.
- The leftover paper is a histogram-shaped rectilinear polygon whose every edge is parallel to the -axis or the -axis. Prodo wants to cut an L-shaped rectilinear polygon out of it.
- An L-shaped rectilinear polygon is a rectilinear polygon with 4 or 6 vertices, where every edge is parallel to the -axis or the -axis.
- A rectilinear polygon with 4 vertices is a rectangle. Cutting a small rectangle from a corner of a rectangle makes an 'L' shape.
For example, when the paper is as shown in Figure 1, Figures 2, 3, and 4 show different ways to make L-shaped rectilinear polygons. There are many other ways too.




From the leftover histogram-shaped rectilinear polygon, find the L-shaped rectilinear polygon with the largest area and help Prodo.
Input
The first line contains the number of vertices of the rectilinear polygon (). Each of the next lines contains the coordinates of a vertex as integers separated by a space (). The starting point of the polygon is the origin , and the vertices are given in clockwise order. Two consecutive vertices form one edge of the rectilinear polygon, and the coordinates are monotonically increasing. Only the starting point and the ending point have coordinate 0. No three consecutive points are collinear.
Output
Print the largest area among the L-shaped rectilinear polygons that can be cut from the given paper, on one line.