#P3162. [CQOI2012] 组装
[CQOI2012] 组装
Description
There are production workshops on the number line that can produce parts. There are types of parts, numbered . The -th workshop is located at coordinate and produces part type (). You need to build an assembly workshop at some position on the number line to assemble these parts. To minimize transportation cost, you need to minimize , where denotes the minimum squared distance from the assembly workshop to any workshop that produces part type .
Input Format
The first line contains two integers , , the number of part types and the number of production workshops. Each of the following lines contains two integers and (). The input is ordered from left to right by workshop position (i.e., ; note that positions may repeat). It is guaranteed that every part type has at least one workshop producing it.
Output Format
Output a single line: the optimal location of the assembly workshop (it may coincide with a production workshop), rounded to four decimal places. It is guaranteed that the optimal location is unique.
3 5
-1 3
0 1
2 3
4 2
5 2
2.0000
Hint
- Test points 1–4: , , .
- Test points 5–10: , , .
Translated by ChatGPT 5
京公网安备 11011102002149号