#P12864. [NERC 2020 Online] Optimum Server Location
[NERC 2020 Online] Optimum Server Location
题目描述
The world's best IT company Oondex is coming to Lineland! After years of facing annoying "This service is not available in your area" error messages, Linelanders will finally be able to listen to the most popular music, watch fresh viral videos and use lots of other opportunities provided by Oondex's services.
Lineland can be seen as a real coordinate line. It has unusual network tariffs: connecting two servers kilometers apart from each other with a network channel of throughput Mbit/s costs dollars.
In order to provide better user experience, Oondex is going to place servers in Lineland. These servers will be performing regular data processing activities which requires intense pairwise network interaction between these servers. At the same time, these servers are going to serve external users using special CDN servers (which are specialized content delivery servers) already present in Lineland.
Analysts of Oondex determined for each pair , () the required throughput Mbit/sec between servers and , and also for each pair , (; ) the required throughput Mbit/sec between server and CDN server .
Given the locations of CDN servers (), determine the locations () such that the cost of placing servers into them is the minimum possible. Formally, determine such that the cost value of $v = \sum\limits_{1 \leq i < j \leq n} |x_i - x_j| \cdot d_{ij} + \sum\limits_{\substack{1 \leq i \leq n \\ 1 \leq k \leq m}} |x_i - a_k| \cdot c_{ik}$ is the minimum possible. Multiple servers (both Oondex and CDN) may be located at the same point.
输入格式
The first line contains two integers and () --- the number of Oondex servers to place and the number of existing CDN servers.
The second line contains integers () --- the locations of existing CDN servers.
The -th of the next lines contains integers where () is the throughput between -th Oondex server and the -th CDN server.
Finally, the -th of the next lines contains integers (; ; ) where is the throughput between -th Oondex server and the -th Oondex server.
输出格式
On the first line output the value --- the minimum possible cost of placing Oondex servers.
On the second line output integers where () --- the coordinates at which the -th Oondex server should be placed. It can be proven that an optimum answer satisfying these restrictions on (range and integrality) exists.
3 4
20 14 5 2
1 2 3 0
3 0 3 0
0 0 0 20
0 15 0
15 0 0
0 0 0
78
9 9 2