my code : http://ideone.com/FUiT5q

what i did was : i created a multiset and push all the elements in the set initially. Now, i check that whether we can make k elements out starting from the first element (as it is the smallest one and if it is not possible then we can guarantee that starting from any other element is also not possible) .I do this as far as possible and increases the count every time .

I am getting WA in all the test cases …if possible then please tell me where my logic is lacking !