Measure a clockwise gap in steps between consecutive numbered points. For a set of selected points, consider the gaps between consecutive selected points in clockwise order, including the gap from the last point back to the first.
The final convex polygon contains the center if and only if every gap is at most . A gap of exactly corresponds to a diameter, so it may place the center on the boundary.
Let be the largest gap between the given points. These gaps are
If , choosing any unoccupied point merely splits one existing gap into two smaller gaps. Every unoccupied point works, so the answer is .
If , this gap must be split. Since the gaps sum to , there is only one gap greater than . Choose a point steps clockwise from its starting point. The two new gaps are and , both of which must be at most . Equivalently,
The answer is therefore .
The input is already sorted, so no sorting is needed. Read the points while keeping only the first point, the previous point, and the largest gap so far. Finally, check the wraparound gap. The time complexity is and the additional space complexity is .
Proof
Consider an edge joining consecutive vertices of the final polygon in clockwise order. If their clockwise gap is , the corresponding central angle is .
The interior of a clockwise convex polygon is to the right of each directed edge. The center is to the right of this edge when the central angle is less than , on the edge when it equals , and to the left when it is greater than . Thus, the center belongs to the closed interior half-plane of this edge exactly when . A convex polygon is the intersection of the closed interior half-planes of all its edges. Therefore, it contains the center exactly when every gap is at most .
Solution written by GPT6
Now consider the gaps between the given points. If they are all at most , adding any unoccupied point preserves this property, so every unoccupied point is valid.
If a gap exceeds , adding a point elsewhere leaves that gap unchanged and cannot produce a valid polygon. Since all gaps sum to , there is at most one such gap, and all other gaps already satisfy the condition. Consequently, splitting the large gap into and is valid if and only if both new gaps are at most .
The valid values of are the integers from through . Since , every such point is strictly between the two endpoints of the large gap. These endpoints are consecutive given points, so all points inside the gap are unoccupied. The number of valid choices is therefore exactly .