It's up to you to decide.
First, the DM has final authority over how XP is divided. The DMG has advice on giving XP, but it gives a lot of variants and ultimately leaves it up to the DM. Therefore, since you're the DM, the real answer to your question is "you decide".
An XP race might be the kind of game your players actually want to play, but that should be discussed with your players and agreed upon ahead of time.
Sharing XP is better for the game.
That being said, DMG 260 states,
When adventurers defeat one or more monsters-typically by killing, routing, or capturing them, they divide the total XP value of the monsters evenly among themselves ... Typically, adventurers earn experience only for encounters they participate in. If a player is absent for a session, the player's character misses out on the experience points.
The key word here is "participate". In your encounter, everyone in the party is participating--they rolled initiative, they took turns, and so they get experience for it.
First, consider the ingame perspective. Sure, the other party members did not actually reduce the HP of the monster, but they could have affected its outcome in other ways. Were they fighting other monsters instead? If so, they could have been keeping those other monsters from ganging up on the lone PC. Even if they were just standing and watching, their presence likely affected the circumstances of the fight, especially if they all took turns. Given that XP is not mere fighting experience (wizards don't learn spells directly from killing), it isn't hard to imagine how they could have learned something from being in the encounter.
Second, consider the out-of-game incentives you're creating for your players. Are you going to divvy up XP according to the share of damage each PC did to each creature? Are you going to encourage the PCs to compete to isolate monsters and go one-on-one? How will you handle some PCs being much better at killing than others?
Because levels are so important in 5e, any XP system other than "everyone gets XP divided evenly" turns the game into a competition for XP. Some of my favorite encounters are ones in which combat isn't the goal--some PCs are trying to save some NPCs, while the others hold off an attacking force, for example. Is it fair if only the PCs that did actual fighting get any XP for that encounter?