#P12864. [NERC 2020 Online] Optimum Server Location

    ID: 12642 Type: RemoteJudge 2000ms 512MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>2020Special JudgeICPCNERC/NEERC

[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 dd kilometers apart from each other with a network channel of throughput tt Mbit/s costs dtd \cdot t dollars.

In order to provide better user experience, Oondex is going to place nn 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 mm special CDN servers (which are specialized content delivery servers) already present in Lineland.

Analysts of Oondex determined for each pair ii, jj (1i<jn1 \leq i < j \leq n) the required throughput dijd_{ij} Mbit/sec between servers ii and jj, and also for each pair ii, kk (1in1 \leq i \leq n; 1km1 \leq k \leq m) the required throughput cikc_{ik} Mbit/sec between server ii and CDN server kk.

Given the locations of CDN servers aka_k (1km1 \leq k \leq m), determine the locations xix_i (1in1 \leq i \leq n) such that the cost of placing servers into them is the minimum possible. Formally, determine xix_i 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 nn and mm (1n,m701 \leq n, m \leq 70) --- the number of Oondex servers to place and the number of existing CDN servers.

The second line contains mm integers a1,a2,,ama_1, a_2, \ldots, a_m (0ak1060 \leq a_k \leq 10^6) --- the locations of existing CDN servers.

The ii-th of the next nn lines contains mm integers ci1,ci2,,cimc_{i1}, c_{i2}, \ldots, c_{im} where cikc_{ik} (0cik500 \leq c_{ik} \leq 50) is the throughput between ii-th Oondex server and the kk-th CDN server.

Finally, the ii-th of the next nn lines contains nn integers di1,di2,,dind_{i1}, d_{i2}, \ldots, d_{in} (0dij500 \leq d_{ij} \leq 50; dij=djid_{ij} = d_{ji}; dii=0d_{ii} = 0) where dijd_{ij} is the throughput between jj-th Oondex server and the ii-th Oondex server.

输出格式

On the first line output the value vv --- the minimum possible cost of placing nn Oondex servers.

On the second line output nn integers x1,x2,,xnx_1, x_2, \ldots, x_n where xix_i (0xi1060 \leq x_i \leq 10^6) --- the coordinates at which the ii-th Oondex server should be placed. It can be proven that an optimum answer satisfying these restrictions on xix_i (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