Sauna
InterviewTime limit1.5sMemory limit1024 MB
Find how many temperatures lie in every person's inclusive range and the lowest such temperature, or report bad news if none exist.
- Level
Easy2 of 10
- Topics
- Array, Implementation
- Solved
- No attempts yet
Problem
Kaisa and her friends are going to the sauna. Each of them has a temperature preference given as an inclusive range. Help them find the temperatures that everyone is happy with.
There may be many possible temperatures, so they only want to know how many options there are and the lowest temperature that works for everyone. The sauna needs less time to heat up at the lowest temperature.
Input
The first line contains an integer , the number of people (). Each of the next lines contains two integers and , meaning the -th person accepts temperatures from to , inclusive. Temperatures are in millidegrees Celsius, with .
Output
Print two integers: the number of temperatures (in millidegrees Celsius) that fit every preference, and the lowest such temperature. If no temperature fits every preference, print "bad news".