#K51542. Sunset Detection
Sunset Detection
Sunset Detection
In this problem, you are given a series of photographs taken during sunset. Each photograph is associated with a timestamp in the format (HH:MM:SS) and a brightness level (an integer). The brightness level of the photos can suddenly drop just before the sunset is complete. Your task is to detect and return the timestamp of the photograph taken immediately before such a sudden brightness drop, where the drop is defined as a decrease of at least 20 units from one photo to the next. If no such drop exists, output the string "No sudden decrease".
The input is provided via standard input (stdin) and the output should be written to standard output (stdout).
inputFormat
The first line of input contains an integer (n) representing the number of photos. The next (n) lines each contain a timestamp and a brightness level. The timestamp is in the format (HH:MM:SS) and the brightness level is an integer. Each value in a line is separated by a space.
For example:
6 18:00:00 85 18:01:00 84 18:02:00 70 18:03:00 50 18:04:00 35 18:05:00 34
outputFormat
Output a single line containing the timestamp of the photo just before the brightness drops by at least 20 units. If no such drop exists in the series, output "No sudden decrease".## sample
6
18:00:00 85
18:01:00 84
18:02:00 70
18:03:00 50
18:04:00 35
18:05:00 34
18:02:00