Crud! Damian is late for a scouts camp but has yet to pack his socks. As he likes to wear matching socks, he needs K socks of the same kind. However, his socks (of N different kinds) are all in a jumble so he decides to just grab a handful of them.
Furthermore, he knows that he has Ai socks of type i.
How many socks does he need to grab to guarantee that he will have at least K socks of one kind?
The first line contains two integers, N and K.
The second line contains N space-separated integers, representing the contents of A.
A single integer representing the minimum number of socks that Damian has to grab. If it is not possible for Damian to guarantee at least K socks, output -1 instead.
3 4 5 5 5
10
Subtask | Score |
---|---|
1 | 30 |
2 | 70 |
3 | 0 |