Crossing the river

After a zombie apocalypse, a group of n survivors were left to die on NP-Land. For days, they fought against hunger, thirst and obviously, zombies. Pursued by the evil creatures, they traveled all over the city and finally arrived at the port. Luckily, they found a small boat, but there’s a problem! The boat has only k seats, and if that wasn’t enough, they will sink if the weight on board is over the limit W. Because of that, the survivors decided to make as many trips as needed to escape from NP-Land. A trip is considered as going from the city’s port to a safe island (or viceversa). There must be at least one person on each trip (in order to drive the boat). You, as the only coder to survive the apocalypse, must help your friends to create an algorithm that minimizes the number of trips. Do it fast! The zombies are knocking on the door! Input The input consists of several test cases. The first line of each test case contains 3 integers, n (1 ≤ n ≤ 16), W (1 ≤ W ≤ 100) and k (1 ≤ k ≤ 6). The next line will contain n integers specifying wi the weight of every survivor (1 ≤ wi ≤ 100). Output For each test case print an integer with an end of line, representing the minimum number of travels or ‘-1’ if it’s impossible. Sample Input 2 100 2 50 50 3 50 2 10 40 40 Sample Output 1 3