Beach cut
Time limit1sMemory limit128 MB
Given a polyline shoreline, pick two vertices at distance at most L and connect them below the shore to maximize the enclosed beach area.
- Level
Medium7 of 10
- Topics
- Geometry, Two pointers, Prefix sum
- Solved
- No attempts yet
Problem

The seashore is modeled as a polyline with no self-intersections, given by its vertices listed in order, whose -coordinates are strictly increasing (). The sea lies above the polyline and the beach lies below it.
You may connect two of these vertices with a single straight segment whose length is at most . Choose the two vertices so that the beach area enclosed between the segment and the shore is as large as possible. The segment must never enter the sea: it may touch the shore polyline but must not cross above it.
Input
The first line contains two integers and . After that come the vertices as integer pairs (whitespace and line breaks may separate the numbers freely).
Output
Print the maximum beach area that can be enclosed (it may be ). Because every vertex has integer coordinates, this area is always an exact multiple of . Print it exactly, with no rounding: as a plain integer when the area is whole, otherwise followed by a single decimal digit (for example, ).
Constraints
- for every