#P2538. [SCOI2008] 城堡

    ID: 1555 远端评测题 800ms 128MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>动态规划,dp搜索2008四川各省省选模拟退火

[SCOI2008] 城堡

Description

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

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

The input guarantees that there exists a solution 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 have castles.

Output Format

Output a single line containing one integer, the minimum 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

100%100\% of the testdata satisfies: 2n502 \leq n \leq 50, 1di1061 \leq d_i \leq 10^6, 0mnk0 \leq m \leq n - k.

Translated by ChatGPT 5