|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|3 초||128 MB||42||18||17||42.500%|
A few friends have decided to do laundry together. They are all very neat, so each day each of the friends wears one clean pair of socks and one clean shirt. The friends have put all dirty socks and shirts to their washing machine. Now they have started to plan how they will dry their laundry. To put this in order, they have decided that:
Now they have scattered all their clothespins on the floor and counted the number of clothespins of each color. Unfortunately, they were not able to figure out which colors should each of them use. Write a program that will help them with this problem.
The first line of input contains two integers n and k (2 ≤ n, k ≤ 1 000 000) denoting the number of friends and the number of clothespins’ colors available. The second line contains n numbers d1, d2, ..., dn representing the number of days each friend was collecting laundry (1 ≤ di ≤ 1 000 000). The third line contains k numbers l1, l2, ..., lk representing the numbers of clothespins of respective colors (1 ≤ li ≤ 4 000 000).
Your program should output the minimal number of clothespins needed to dry all the laundry. If it is not possible to dry all the laundry in the requested manner, your program should output a single word NIE (i.e., no in Polish).
2 4 3 4 20 10 8 10
3 8 5 4 3 14 14 14 14 14 14 14 14
Explanation for the first example: The first person needs 6 clothespins for her socks and 9 clothespins for her shirts. The second person needs 8 clothespins for her socks and 12 clothespins for her shirts. The second person should use the clothespins of the first color both for her socks and her shirts. The first person may then use, e.g., the clothespins of the second and the fourth color.