Given n points, some possibly repeated, count the corners of their convex hull: the smallest convex polygon that contains all the points. A point that lies in the middle of an edge, or strictly inside the hull, is not a corner. Repeated copies of one point count once.
The first line has n. Each of the next n lines has the coordinates x y of one point.
Print one integer: the number of corners of the convex hull.
1 <= n <= 200000 |x|, |y| <= 10^9
1000 ms256 MB
5 0 0 4 0 4 4 0 4 2 2
4
The square's four corners are the hull corners. (2,2) lies inside, so it is not a corner.
4 0 0 1 1 2 2 3 3
2
All four points lie on one line. The hull is a segment, and only its two ends are corners.
1 5 5
1
A single point is its own hull, with one corner.