生日聚会

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

Background

QQ 过生日啦!

Description

QQ 邀请了 nn 个人,除了小 QQ 没有讨厌的人之外,其他人都有一个讨厌的人。

而第 ii 个人来就可以获得 aia_i 的欢快值。

但由于场地有限,所以最多只能容纳 mm 个人,小 QQ 想知道欢快值最大是多少?

Format

Input

第一行一个整数 n,mn,m

接下来 n1n-1 个整数,f2,f3,...fn(1fi<i)f_2,f_3,...f_n(1 \le f_i < i) 表示 ii 讨厌的人。

接下来 nn 个整数,表示 a1,a2,...,ana_1, a_2,...,a_n 代表每个人的欢快值。

注意,小 QQ 也可能不去(

Output

一行一个整数,表示答案。

Samples

5 2
1 2 3 1
1 8 10 8 2
16

Limitation

对于所有数据,保证 2n500,0mn,1ai1000002\leq n\leq 500,0\leq m\leq n,1\leq a_i\leq 100000

非常好看

Not Attended
Status
Done
Rule
Ledo
Problem
40
Start at
2025-1-24 16:45
End at
2025-4-18 0:45
Duration
2000 hour(s)
Host
Partic.
17