Problem description, Inputs and Outputs:
This one is so easy, first of all when i first read the description very quick i thought it was like a knapsack problem, but then i read it again and realize that you only need the weights in increasing order and try to grab as many eggs as possible, and then i realize that it says that they already give you the numbers in NON-DECREASING order (that is just another way to say they are in INCREASING order :D) so you don’t have to even worry about using qsort or something similar, you just grab the numbers and start putting eggs into your bowl until one of three situation occur:
1) you have P eggs (cause thats the maximum amount of eggs you can have)
2) you have Q gm of eggs already in your bowl (cause thats the maximum weight you can handle)
3) the more obvious one, you ran out of eggs XD
so this can be easily solved by a loop, there are no special cases so you don’t need to worry about that.