Time limit
2s
Memory limit
128 MB
A polygon is convex if the segment connecting any two of its vertices always lies inside the polygon. In this problem, only polygons whose interior angles are all strictly less than 180 degrees are considered convex.
You are given N distinct points on a two-dimensional plane. By choosing some of these points as vertices, you can form the outermost convex polygon that contains every given point inside it or on its boundary. This polygon is the convex hull of the point set.
Write a program that finds the number of vertices on the convex hull formed by the given points.
The first line contains the number of points N. (3 <= N <= 100,000)
Each of the next N lines contains the x-coordinate and y-coordinate of one point, separated by a space. All points are distinct, and the absolute value of every coordinate is at most 40,000.
The input points are not all on one straight line.
Print the number of points that form the convex hull on the first line.
If several points lie on the same edge of the convex hull, count only the two endpoints of that edge.