When trying to solve the puzzle, you'll be given 20 seconds to line up enemies in order to execute your attack.
But 20 seconds may not seem like a lot of time, so you may want to consider getting more.
Here's how to get more time in battle.
How To Get More Time In Battle In Paper Mario: The Origami King
To get more time, you can simply buy it.
You'll notice in the top right of the screen is a prompt to buy more time.
Simply hold the + button on your Joycon and it will start to give you more time. For every second you buy, it will cost you 10 coins.