题目描述
Problem Description
$ N $ T-shirts are on sale. Each T-shirt is represented by an integer color between $ 1 $ and $ 10^9 $, inclusive. The color of the $ i $th T-shirt is $ c_i $ and its price is $ p_i $ yen.
What is the minimum amount of yen needed to collect $ K $ different colors of T-shirts?
If it is impossible to collect $ K $ different colors of T-shirts, output -1.
Input Format
The input is given from the standard input in the following format:
$ N $ $ K $ $ c_1 $ $ c_2 $ $\ldots$ $ c_N $ $ p_1 $ $ p_2 $ $\ldots$ $ p_N $
Output Format
Output the answer (excluding the unit).
Sample Input and Output
Sample Input #1
3 2
2 1 2
3 4 5
Sample Output #1
7
Sample Input #2
3 3
2 1 2
3 4 5
Sample Output #2
-1
Sample Input #3
4 2
4 10 2 4
1 5 3 2
Sample Output #3
4
Notes/Hints
Constraints
- $1 \leq N \leq 10^5$
- $1 \leq K \leq N+1$
- $1 \leq c_i, p_i \leq 10^9$
- All inputs are integers.
Sample Explanation 1
Buying the 1st and 2nd T-shirts is the optimal choice.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分
样例输入
3 2
2 1 2
3 4 5
样例输出
7