Convex Polygons
Time limit1sMemory limit1024 MB
Find the longest contiguous run of points that forms a convex polygon in counterclockwise order, and report its length.
- Level
Medium7 of 10
- Topics
- Array, Two pointers, Geometry
- Solved
- No attempts yet
Problem
A set of points is given on the 2D coordinate plane. Find the maximum value of over all integers and that satisfy the following conditions.
- , and .
- form a convex polygon in counterclockwise order. Every interior angle is less than 180 degrees.
Input
The first line contains the number of points . ()
Each of the next lines contains two integers and , the x and y coordinates of the -th point. ()
All given points are distinct.
Output
Print the maximum value of over all pairs and that satisfy the conditions. If no such pair exists, print .
Hint
A convex polygon is a simple polygon (one that does not cross itself) where every segment joining two points on its boundary stays inside the polygon.