You are given a int[] cards, the i-th element of which is the number of cards you have of type i, and an int jokers, the number of jokers you have. You want to construct decks using these cards. There are two types of valid decks:
- A deck containing exactly 1 card of each type, and no jokers.
- A deck containing exactly 1 card of each type except one, and exactly 1 joker.
For example, if there are 3 types of cards, the following four decks would be valid: {1, 2, 3}, {J, 2, 3}, {1, J, 3}, {1, 2, J}. Return the maximum possible number of valid decks you can construct with the given cards. Each card can only be a member of a single deck.
|