#P9568. Maximum Subpolygon Area in a Convex Polygon

    ID: 22715 Type: Default 1000ms 256MiB

Maximum Subpolygon Area in a Convex Polygon

Maximum Subpolygon Area in a Convex Polygon

You are given a convex polygon \( P \) with \( n \) vertices (listed in counter-clockwise order) and an integer \( k \). You need to choose three distinct vertices of \( P \), denoted by \( a \), \( b \), and \( c \) in counter-clockwise order such that there are exactly \( k \) edges from \( b \) to \( c \) along the boundary of \( P \) (i.e. if you start at \( b \) and move counter-clockwise, after traversing exactly \( k \) edges you reach \( c \); note that \( a \) is not included among the endpoints of these \( k \) edges).

After choosing the vertices, we form a new polygon \( Q \) as follows: take the segments \( ab \) and \( ac \) together with the \( k \) consecutive edges between \( b \) and \( c \) (as they appear on \( P \)). Thus, \( Q \) is a polygon with \( k+2 \) vertices. Your task is to find the maximum possible area of \( Q \) over all valid choices.

Note: The segments \( ab \) and \( ac \) may coincide with edges of \( P \).

Mathematical formulation:

Let the vertices of \( P \) be \( V_0, V_1, \dots, V_{n-1} \) in counter-clockwise order. For any index \( b \) (\( 0 \le b < n \)), define \( c = (b+k)\bmod n \). A vertex \( a \) is valid if it lies on the arc from \( c+1 \) to \( b-1 \) (cyclically) so that the order \( a, b, c \) holds. For a fixed choice, let the polygon \( Q \) have vertices \( (a, V_b, V_{b+1}, \dots, V_c) \) (indices considered modulo \( n \)). Compute the area of \( Q \) using the standard shoelace formula. You are to maximize this area.

inputFormat

The first line contains two integers \( n \) and \( k \) (with \( n \ge k+2 \)). The next \( n \) lines each contain two real numbers representing the coordinates of the vertices of the convex polygon \( P \) given in counter-clockwise order.

For example:

5 1
0 0
4 0
5 3
2 5
-1 3

outputFormat

Output a single number: the maximum possible area of \( Q \). Your answer will be considered correct if its absolute or relative error does not exceed \( 10^{-6} \).

sample

5 1
0 0
4 0
5 3
2 5
-1 3
10.000000

</p>