#P1862. 输油管道问题
输油管道问题
Description
An oil company plans to build a main pipeline running from east to west.
The pipeline must pass through an oil field that has wells. From each well, a feeder pipeline must connect to the main pipeline along the shortest path (either north or south).
Given the positions of the wells, with their coordinates (east–west) and coordinates (north–south), determine the optimal position of the main pipeline so that the total length of the feeder pipelines from the wells to the main pipeline is minimized. Prove that the optimal position of the main pipeline can be determined within the time limit.
Input Format
The first line contains the number of wells .
Each of the next lines contains the position of a well: two integers and .
Output Format
Output a single line with the minimum total length of the feeder pipelines from the wells to the main pipeline.
5
1 2
2 2
1 3
3 -2
3 3
6
Hint
Constraints
For all testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号