This question is explored in the June 2005 issue of the Journal of Consumer Research. According to the research of Loraine Lau-Gesk (University of California at Irvine), the answer lies in the ability to draw a connection between a presently bad experience and previously good one.
Lau-Gesk explains that the issue has to do with "'affective source similarity,' or the level of similarity that a person views the source of the negative and positive experience."
Traditionally a split has existed between researchers who either believe that a combined positive and negative experience will increase discomfort and those that believe that a negative experience can actually lead to a positive experience. Though Lau-Gesk does confirm that discomfort will accompany a combined bad and good experience, "people will also find comfort in ambivalence if a bad experience is compared immediately to a good one. These implications may also [offer] some predictive consumer behavior benefit for marketing and advertising professionals who design strategic advertising campaigns."
"Understanding Consumer Evaluations of Mixed Affective Experiences." Loraine Lau-Gesk. Journal of Consumer Research. June 2005.
Journal
Journal of Consumer Research