There’s an unexpected wistfulness, a bittersweet undercurrent to “Going the Distance” that could not have been in the script. This romantic comedy co-starring Drew Barrymore and longtime beau Justin Long was finished just as the real life couple was splitting up. For good, this time.

So it has baggage. That may explain why it’s been dumped on Labor Day weekend.

But that baggage tends to give this R-rated romance resonance. It’s formulaic and loses its mushy/silly momentum at about the one-hour mark. But the truths — funny and otherwise — about long-distance relationships allow documentary maker Nanette Burstein’s first fiction feature to do that one thing that a romance absolutely has to do — touch us.

Justin is Garrett, a hip New York artist rep at a small record label. He has goofy friends (Jason Sudeikis, Charlie Day) and no clue about women. We meet him as he is dumped for botching his girlfriend’s birthday.

Drew plays Erin, at 31 entirely too old to be doing a New York newspaper internship.

“You are behind in your life,” her irritable sister (Christina Applegate, terrific) reminds her. Like Erin needs reminding.

“I’m 31. I’m an intern. I’m going to get wasted.”

The two 30somethings “meet cute” — a profane exchange over a Centipede arcade game. And, over many drinks and their variation of Truth or Dare, they connect.

Her: “How would you like to die?”

Him: “Eating tortellini. Or getting water-boarded.”

Geoff LaTulippe’s script is sort of an arrested-development guy’s fantasy about what dating can be — a woman able to hang with you in movie trivia, better than you at video games, capable of trading Jagermeister shots and monster bong hits without wheezing.

The obstacle to this romance? Her internship is ending. She’s got to finish her degree at Stanford. And since newspapers haven’t been in a hiring mode for the past few years, the chances of this romance going anywhere are slim.

Burstein follows the modern romance formula to a fault — “date” montages edited to pop songs — while touching on the inevitable stresses of long distance. The language is coarse, the sex kind of graphic, the drinking constant and the “best friends” (or sister) characters carry their share of the load.

But “Going the Distance” manages more than a few moments that hit close to home. We buy them as a couple because they’re both following their dreams into professions going through traumatic changes. No, there really are no record label jobs in San Francisco or newspaper jobs in NYC. How do you get past that?

And the way these two tumble is both adult and romantic. They don’t want it to happen.

Her: “I’m only here for a couple more weeks.”

Him: “Maybe you’ll come back one day.”

You have to be pretty cynical not to hear the heart in that, or to simply root for these two as a couple, at least on the screen.