There are n coordinates. The area of the shape using those n coordinates according to the statement. The given figure shows what it may look like. The area of the purple polygon will be output.

Here, these things should be observed,

A point $p_i$ is considered left to $p_j$ if $x_{p_i}<x_{p_j}$.

A point $p_i$ is considered right to $p_j$ if $x_{p_i}>x_{p_j}$.

There can be multiple coordinates with the same $x$-value. In this case, only considering the coordinate with the maximum $y$-value is to be considered as it will cover all the coordinates below while creating the shape.

While calculating area, The intersecting point of two adjacent triangles’ sides is to be found out. Then the area can be easily calculated using the shoelace theorem or triangle area or any other method. The implementation is up to the solvers.

Analysis and solutions: link to repository.

Toph uses cookies. By continuing you agree to our Cookie Policy.