#P2454. [SCOI2008] 城堡 - 数据加强版

    ID: 1460 远端评测题 1500ms 512MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>字符串2006各省省选山东二分图费用流

[SCOI2008] 城堡 - 数据加强版

Description

In a country, there are nn cities (numbered 00 to n1n-1). These cities are connected by nn bidirectional roads (numbered 00 to n1n-1). Road ii connects city ii and city rir_i (a road may connect a city to itself), with length did_i. Among the nn cities, mm of them have their own castles, which can resist enemy invasions. When a city without a castle is attacked, the nearest castle will send troops to rescue.

Your task is to build castles in at most kk cities that currently do not have castles, so that the maximum “distance to the nearest castle” among all cities is as small as possible. In other words, let dist(c)dist(c) be the distance from city cc to its nearest castle; your goal is to minimize max{dist(c)}\max\{dist(c)\}.

It is guaranteed that there exists a plan such that for every city, at least one castle can reach it.

Input Format

The first line contains three positive integers n,m,kn, m, k. The second line contains nn integers r0,r1,,rn1r_0,r_1,\ldots,r_{n-1}. The third line contains nn integers d0,d1,,dn1d_0,d_1,\ldots,d_{n-1}. The fourth line contains mm distinct integers between 00 and n1n-1, which are the indices of the cities that already have castles.

Output Format

Output a single line containing one integer: the minimum possible value of max{dist(c)}\max\{dist(c)\}.

5 0 1
1 2 3 4 0
1 1 1 1 1
2
3 1 1
1 2 0
1 2 3
2
1
2 1 1  
0 1  
1 1  
1
0
10 3 3
0 2 0 0 2 2 8 3 8 7
10 9 1 8 1 3 7 2 8 1
3 4 6
3
2 0 1
1 0
5 10
5

Hint

Constraints:

100%100\% of the testdata satisfies 1di1051\leq d_i\leq 10^5 and 0mnk0\leq m\leq n-k.

  • Subtask 1: 2n30002 \leq n \leq 3000.
  • Subtask 2: 2n1052 \leq n \leq 10^5.

Translated by ChatGPT 5