Playrix Codescapes Cup (Codeforces Round 413, rated, Div. 1 + Div. 2)
E
Aquarium decoration
Codeforces
2500
原题
← DF →
翻译中…

Arkady and Masha want to choose decorations for thier aquarium in Fishdom game. They have $*n*$ decorations to choose from, each of them has some cost. To complete a task Arkady and Masha need to choose exactly $*m*$ decorations from given, and they want to spend as little money as possible.

翻译中…

There is one difficulty: Masha likes some $*a*$ of the given decorations, Arkady likes some $*b*$ of the given decorations. Some decorations may be liked by both Arkady and Masha, or not be liked by both. The friends want to choose such decorations so that each of them likes at least $*k*$ decorations among the chosen. Help Masha and Arkady find the minimum sum of money they need to spend.

翻译中…

Input

翻译中…

The first line contains three integers $*n*$, $*m*$ and $*k*$ ($1 ≤ *n* ≤ 200000$, $1 ≤ *m* ≤ *n*$, $1 ≤ *k* ≤ *n*$) — the number of decorations, how many decorations the friends should choose, how many decorations each of them should like among the chosen.

翻译中…

The second line contains $*n*$ integers $*c*_{1}, *c*_{2}, ..., *c*_{*n*}$ ($1 ≤ *c*_{*i*} ≤ 10^{9}$) — decorations costs.

翻译中…

The third line contains single integer $*a*$ ($1 ≤ *a* ≤ *n*$) — the number of decorations liked by Masha. The fourth line contains $*a*$ distinct integers $*x*_{1}, *x*_{2}, ..., *x*_{*a*}$ ($1 ≤ *x*_{*i*} ≤ *n*$) — the ids of decorations liked by Masha.

翻译中…

The next two lines describe decorations liked by Arkady in the same format.

翻译中…

Output

翻译中…

Print single integer: the minimum sum of money the friends should spend to fulfill all constraints. If it is not possible, print -1.

翻译中…

Note

翻译中…

In the first example the only possible variant to choose $3$ decorations having all conditions satisfied is to choose decorations $1$, $2$, $3$.

翻译中…

In the second example friends can choose decoration $4$ instead of decoration $3$, because this one is one coin cheaper.

翻译中…

In the third example it's not possible to choose $2$ decorations in a way that both are liked by both Masha and Arkady.

翻译中…

样例

Input #1
4 3 2
3 2 2 1
2
1 2
2
1 3
Output #1
7
InputCopy OutputCopy
Input #2
4 3 2
3 2 2 1
2
1 2
3
4 1 3
Output #2
6
InputCopy OutputCopy
Input #3
4 2 2
3 2 2 1
2
1 2
3
4 1 3
Output #3
-1
InputCopy OutputCopy
题目信息
题号
799E
时间限制
2 s
内存限制
256 MB
标签
数据结构
贪心
双指针

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。