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,

  1. A point pip_i is considered left to pjp_j if xpi<xpjx_{p_i}<x_{p_j}.

  2. A point pip_i is considered right to pjp_j if xpi>xpjx_{p_i}>x_{p_j}.

  3. There can be multiple coordinates with the same xx-value. In this case, only considering the coordinate with the maximum yy-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.


80% Solution Ratio
tanzim_bnEarliest, Feb '23
Sk_SabitFastest, 0.1s
Sk_SabitLightest, 13 MB
tanzim_bnShortest, 843B
Toph uses cookies. By continuing you agree to our Cookie Policy.