I'll add my two cents, as there are many ways to approach this situation and many great answers already.
Firstly, it's nobody's fault, here.
One, as a DM, I would never want to restrict my characters. I've found that Dungeons and Dragons is a game that has as playstyle for everyone, and I don't see any reason to say, "You can't split up","You can't sit on the beach all day," etc. On the other hand, some players might not exactly know what they could be doing. Perhaps they walked to the beach to lounge, just for the sake of lounging. Or, perhaps they went there thinking they might find treasure, but not know how to go about looking for it. Maybe they went there to have a nice relaxing beach day, but being the clever DM you are, you unleash a mimic in the form of a treasure chest on them, or an army of crabs.
As a DM, you have the important, difficult, and tedious task of keeping everyone engaged and happy, but that includes yourself. It helps to have talks with your group, and discuss what each player is looking for out of each session, and to communicate what you as the DM wish for your campaign that you are running.
There will always be unforeseen circumstances, and the players and the DM can be taken off guard by things that weren't planned for. The best you can do is attempt to make the most fun out of every situation. Perhaps it started pouring rain on the beach that day, forcing them to return back to town, and quite possibly back into the group.
It's a challenging job being the DM, but it's a very rewarding task to have.
As a group, we always had a 3 hour long session, sometimes a little longer if in the middle of a battle, and sometimes shorter if we needed to call it early, but we always invited everyone to an "after-session" where we could all talk about the session and how it went; any concerns; any plans for bettering a future session; any things we really liked about past sessions. This was time we just kinda hung out, but it helped us to talk about our sessions, and drove them into a direction we all enjoyed a lot more.
An important thing to remember is that it's not your fault or theirs if things start to go a little on the boring side. Some people do have off days, and their creative juices just aren't flowing. If the party splits up, that's okay. Just make sure you delegate enough attention to each player, and perhaps explain to the group what splitting up the party does, so that they might think twice before doing it in the future. However, it happens.
Carry on with Dogor the Half-Orc fighter as he walks through the back alley to confront the drug smuggler, but remember that Orin the Elvish Bard is back at the tavern trying to schmooze his way up to the daughter of a wealthy aristocrat. And if Helen the Human Sorcerer is just waiting on a beach doing nothing, when it comes time for her attention, ask her, what are you here for? Would you like to inspect the water or go for a swim (keeping your shark attack secretly tucked in your sleeve)? Would you like to build a sand-castle, who knows, you might find treasure in the process (it's an item that leads to a new quest)? You arrive on the beach, but notice smoke off to one side of the beach, and a faint sound of drums (a goblin beach party, anyone?). Some player's thrive better when they have things thrown at them to react to, as opposed to coming up with the idea themselves.
Try to entice your players into having fun when you think they are at a loss as to what to do. But, always make sure every player feels like they're getting a fair share of the time if they split up.
The most important thing is to have fun, regardless of what happened in the situation and how it went. Everyone plays different. But you can all have the same amount of fun.