Sanjay, the monkey, is playing a game with some cards! Sanjay has a deck of
The game consists of
Sanjay is setting up the decks before Tony arrives and can shuffle them into any order he chooses, but he cannot swap cards between decks. What order should he put the cards in so he achieves the most points?
Constraints
Input Specification
The first line of input will contain
The next line of input will contain
The final line of input will contain
Output Specification
The first line of output should contain the highest possible score if Sanjay arranges the decks optimally.
The second line of output should contain the optimal arrangement of deck
The final line of output should contain the optimal arrangement of deck
If there are multiple valid arrangements, output any of them.
Note: The checker is strict; do not output any extra whitespace.
Sample Input
5 4
4 4 4 4 4
5 2 1 3 1
Sample Output
2
4 4 4 4 4
3 5 2 1 1
Explanation
Sanjay scores a point on the second and fifth round.
Comments