The peak-end rule
It turns out that, when considering how enjoyable, or indeed how painful something was, we don’t mentally do an average enjoyment check to decide if it was good or bad. Our minds are swayed by the peak and end levels. So, an experience that may have been dull for most of it, if it had a cracking bit in the middle and ended on a high, will generally be remembered as more enjoyable than something that was decent all the way through but never reached those highs.
Here’s a classic study of the pain side of the phenomenon from Dan Kahneman:
"Kahneman and his associates showed, in 1993, that participants exposed to 30 seconds of 14-degree ice water (very cold!) rated the experience as more painful than participants exposed to 90 seconds of exposure to 60 seconds of 14-degree ice water plus 30 additional seconds of 15-degree ice water. In other words, participants found the 90 seconds of ice water exposure less painful than those exposed to 60 seconds of nearly equally cold water because the 90 seconds ended with exposure to a “warmer” stimulus. We will rate an experience as less painful then if it ends on a slightly less painful way. The “peak-end” in this case was a one-degree difference in water temperature."
From Susan Krauss-Whitbourne PhD, Happiness: it’s all about the ending, Psychology Today .