Editorial for COCI '09 Contest 2 #6 Pasijans
Submitting an official solution before solving the problem yourself is a bannable offence.
Let us try to form a greedy strategy. The question we need to answer is, what deck do we take the card to form the best solution sequence? Let's examine all top cards on all decks. If there is only one smallest card, it is obvious we need to choose that deck. Any other deck yields worse solution sequences. The problem is if more than one deck shares the smallest card. We now examine the prefixes of those decks. For simplicity, we only present a case with two decks. Extension to more decks is simple. Let's examine decks
Comments