I'm a young wizard, and I try very hard to not waste mana during my magical encounters.
I have X spells available at any given time and each one of them have its own mana cost Y.
X,Y being positive integers strictly lower than 11.
As a beginner, my mana pool fluctuates a lot (it is always lower than 11), and I need help to cast as few spells as possibles (scrolls are expensive, ya know) while emptying my mana pool. If you can't find any spell combination which matches exactly my mana pool's size, you shall then offer me closest (and cheaper) one.
I came to you and your infinite wisdom to help me become the greatest dark wizard. I shall not be disappointed.
INPUT style (because style is everything):
Y;a b c d e f
Y is the size of the mana pool. (a,b,c,d,e,f) are the spells. There are 6 spells, first one costs 'a' mana, second spell costs 'b' mana, etc.
INPUT : 4;1 2 3 3 7 6
I have 4 manas available, and 6 spells available. Two spells cost 1 mana, 1 spell costs 2 mana, two spells cost 3 mana, etc.
OUTPUT : (3,1)
INPUT : 3;1 3 5 2 10
OUTPUT : (3)
INPUT : 8 ; 4 1 9
OUTPUT : (4,1)
INPUT : 4;1 2 2 3
OUTPUT : (2,2),(1,3)
You shall output every combination of spells, but there is no need to distinct spells which are the same cost.
The shortest incantation to whatever machine you desire will be granted a profusion of thanks, and a whip of destiny.