PROGRAMMING:Oil pipeline problems
An oil company plans to build a main oil pipeline from east to west. The pipeline will pass through an oil field with n oil wells. From each oil well, an oil pipeline should be connected with the main pipeline along the shortest path (or south or North). Given the location of n oil wells, i.e. their x-coordinate (east-west) and y-coordinate (north-south), how to determine the optimal location of the main pipeline, even if the total length of oil pipelines from each oil well to the main pipeline is the smallest? It is proved that the optimal position of main pipeline can be determined in linear time.
Given the location of n oil wells, the sum of the minimum length of oil pipeline from each oil well to the main pipeline is calculated.
###Input format:
The first line of input is the number of wells n, 1 < = n < = 10000. The next N lines are
The location of the oil well, 2 integers x and Y cut by spaces in each line, - 10000 < = x, y < = 10000.
###Output format:
The sum of the minimum length of the pipeline from the output well to the main pipeline.
###Input example:
```in
five
1 2
2 2
1 3
3 -2
3 3
```
###Output example:
```out
six
```
answer:If there is no answer, please comment
Given the location of n oil wells, the sum of the minimum length of oil pipeline from each oil well to the main pipeline is calculated.
###Input format:
The first line of input is the number of wells n, 1 < = n < = 10000. The next N lines are
The location of the oil well, 2 integers x and Y cut by spaces in each line, - 10000 < = x, y < = 10000.
###Output format:
The sum of the minimum length of the pipeline from the output well to the main pipeline.
###Input example:
```in
five
1 2
2 2
1 3
3 -2
3 3
```
###Output example:
```out
six
```
answer:If there is no answer, please comment