CF799E.Aquarium decoration
省选/NOI-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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.
阿尔卡季和玛莎想为他们在《Fishdom》游戏中的水族箱挑选装饰品。他们共有 n 个装饰品可供选择,每个装饰品都有一定的价格。为了完成任务,阿尔卡季和玛莎需要从这 n 个装饰品中恰好挑选 m 个,且希望花费的总金额尽可能少。
但存在一个限制条件:玛莎喜欢其中 a 个装饰品,阿尔卡季喜欢其中 b 个装饰品。某些装饰品可能同时被两人喜欢,也可能两人都不喜欢。两位朋友希望所选的 m 个装饰品满足:每人至少喜欢其中 k 个。请帮助玛莎和阿尔卡季找出满足条件的最小总花费。
输入格式
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 ≤ 109) — 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.
第一行包含三个整数 n、m 和 k(1 ≤ n ≤ 200000,1 ≤ m ≤ n,1 ≤ k ≤ n)—— 分别表示装饰品总数、朋友们需选择的装饰品数量,以及每人需在所选装饰品中喜欢的数量。
第二行包含 n 个整数 c1, c2, ..., cn(1 ≤ ci ≤ 109)—— 各装饰品的价格。
第三行包含一个整数 a(1 ≤ a ≤ n)—— 玛莎喜欢的装饰品数量。第四行包含 a 个互不相同的整数 x1, x2, ..., xa(1 ≤ xi ≤ n)—— 玛莎喜欢的装饰品编号。
接下来两行以相同格式描述阿尔卡季喜欢的装饰品。
输出格式
Print single integer: the minimum sum of money the friends should spend to fulfill all constraints. If it is not possible, print -1.
输出一个整数:朋友们为满足所有约束条件所需花费的最少金额。若无法满足,则输出 −1。
输入输出样例
输入#1
4 3 2 3 2 2 1 2 1 2 2 1 3
输出#1
7
输入#2
4 3 2 3 2 2 1 2 1 2 3 4 1 3
输出#2
6
输入#3
4 2 2 3 2 2 1 2 1 2 3 4 1 3
输出#3
-1
说明/提示
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.
在第一个例子中,唯一满足所有条件的、选择 3 个装饰品的方案是选择装饰品 1、2、3。
在第二个例子中,朋友们可以选择装饰品 4 代替装饰品 3,因为前者便宜一枚硬币。
在第三个例子中,无法选择 2 个装饰品,使得它们同时被玛莎和阿尔卡季所喜欢。
输入解题思路,AI测评打分。不知道怎么写?