Harmonic Hideout
면접 대비시간 제한1초메모리 제한1024 MB
K개 종류 중 정확히 N개를 골라, 겹칠 수 있는 두 선호 집합 각각에서 최소 M개를 포함하면서 총비용을 최소화한다.
문제
Hanbyeol and Eunha have finalized a real estate contract to create their secret hideout. They plan to shop for household appliances to make it both cozy for living and fun for spending time. They aim to fit exactly appliances into their limited hideout space.
They can choose from types of appliances at the appliance store, each with its own price. Hanbyeol and Eunha want to acquire appliances at the lowest possible cost.
However, they cannot simply choose any appliances. Hanbyeol prefers types of appliances, and Eunha prefers types. Their preferences may overlap. To reach a compromise, they have agreed that among the appliances, at least appliances must be from the types Hanbyeol prefers, and at least appliances must also be from the types Eunha prefers.
Please help Hanbyeol and Eunha decide which appliances to purchase under these conditions.
입력
The first line contains two space-separated integers: , denoting the count of appliances that fit in the hideout, and , denoting the count of the types of appliances that the appliance store has. ()
The following line contains three space-separated integers: , denoting the minimum count of bought appliances that must be from the types favored by each girl; , denoting the number of types that Hanbyeol prefers; and , denoting the number of types that Eunha prefers. ()
The following line contains space-separated integers: , where denotes the cost of the -th type of appliance that the store has. ()
The following line contains space-separated integers: , denoting the index of appliances that Hanbyeol prefers. ( )
The following line contains space-separated integers: , denoting the index of appliances that Eunha prefers. ( )
출력
Output the minimum cost to fulfill all constraints. If it is impossible, output -1 instead.