Projected Array
Time limit3sMemory limit1024 MB
Rotate N numbered points around the origin, project them onto the x-axis, and find the minimum number of inversions in the resulting label order.
- Level
Medium7 of 10
- Topics
- Geometry, Sorting, Implementation
- Solved
- No attempts yet
Problem
There are distinct points on a two-dimensional plane. Each point has a different integer from to written on it.
Now rotate every point around the origin by a certain angle and project them onto the -axis. Read the points in increasing order of their -coordinates, and the numbers written on them form a sequence of length . However, no two points may have the same -coordinate after rotation. Among the sequences that can be made this way, find the minimum number of inversions.
Here, the number of inversions of a sequence is the number of pairs with and .

Input
The first line contains the number of points . ()
The next lines each contain two integers and separated by a space, the coordinates of the point that has the integer written on it. (; )
Output
On the first line, print the minimum possible number of inversions.