Triangles and a Circle
Time limit1sMemory limit512 MB
Count triangles formed by n points on a circle of circumference L whose interior or border contains the circle's center.
- Level
Medium7 of 10
- Topics
- Two pointers, Combinatorics, Geometry, Sorting
- Solved
- No attempts yet
Problem
You are given distinct points on a circle of length .
Find the number of triangles with vertices at these points that contain the center of the circle inside or on their border.
Input
The first line contains two integers and (, ).
Pick any point on the circle and call it . Then any point on the circle can be written as with , the clockwise distance from to . We call this number the coordinate of .
The second line contains distinct integers , the coordinates of the given points ().
Output
Print one integer: the number of triangles with vertices at the given points that contain the center of the circle inside or on their border.