#Lutece1248. Stage Lighting
Stage Lighting
Migrated from Lutece 1248 Stage Lighting
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
在一个舞台上从左到右摆放着盏灯,灯的编号是到,第盏灯的功率是。
当点亮的灯的总功率之和不小于时,演出就开始啦!
点亮一盏灯,需要连上一定数量的电源。第盏灯如果要点亮,需要将它和个电源相连,电源的编号分别是, , , 。
现在舞台一共有个电源,编号从到,每个电源同时最多只能和一盏灯相连。
给定以上信息,你需要对每个,求出最小的,使得可以从中选一些灯点亮,使演出开始,如果这样的不存在,输出。
Input
第一行输入, 和。(, , )
第二行包括个整数, , , ,表示每盏灯的功率。()
接下来行,第行的第一个数字为,表示点亮第盏灯需要的电源个数()。之后的个数,, , , ,表示对应电源的编号。()
Output
输出行,每行是对应的。
Samples
6 3 6
3 1 3 5 6 4
1 2
1 3
1 1
1 2
3 1 2 3
2 1 3
3
4
4
5
5
-1
Resources
2015 Russian Code Cup