GFSSOC '15 Fall S2 - Hearth

View as PDF

Submit solution


Points: 5 (partial)
Time limit: 2.0s
Memory limit: 64M

Authors:
Problem type

One of Calvin's favourite pastimes is playing Super-Hearthstone with his friends! In Super-Hearthstone, mana crystals are used to play spells and creatures. Each card has a cost, which when played will expend that many mana crystals. Of course, you cannot play a card if you do not have enough of these crystals. Now, Calvin is very good at Super-Hearthstone, but he has not once managed to beat Super-Grandmaster Awaykened. Why? Because Super-Grandmaster Awaykened is adept at seeing through all possible moves! Currently, master Calvin is in a game against Awaykened, has N cards in his hand, and can only use T mana crystals this turn. The i^{th} card costs C_i mana crystals, and has a unique name S_i. Being Calvin's lackey second in command, you need to help him beat Awaykened by listing all the possible three card combinations.

Input Specification

Line 1: Two integers, space separated — N, T.

Next N lines: S_i and C_i, representing one card in Calvin's hand. The length of the card name will be one word long, all capitals, and less than or equal to 20 characters.

Output Specification

For each combination, list out the names of the three cards, space separated and sorted by lexicographic order. Combinations should be on one line each, and they should also be sorted lexicographically as well, with respect to pairwise comparisons of each of the three cards in the combination. If there are no possible three card combinations, do not output anything.

Constraints

1 \le N \le 10

1 \le T \le 30

1 \le C_i \le 10

Sample Input

5 5
KNIFEJUGGLER 2
HAUNTEDCREEPER 2
STONETUSKBOAR 1
LORDJARAXXUS 9
ANNOYOTRON 2

Sample Output

ANNOYOTRON HAUNTEDCREEPER STONETUSKBOAR
ANNOYOTRON KNIFEJUGGLER STONETUSKBOAR
HAUNTEDCREEPER KNIFEJUGGLER STONETUSKBOAR

Comments


  • 2
    jerrytian  commented on March 20, 2018, 2:42 p.m.

    why can i have 30 mana crystals in one turn


  • 6
    TheZombieCloud  commented on June 13, 2017, 11:23 p.m.

    There is an extra space between KNIFEJUGGLER and 2 in the sample input.