Editorial for COCI '06 Contest 5 #2 Natrij
Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
Submitting an official solution before solving the problem yourself is a bannable offence.
For both given times, we'll calculate the number of seconds elapsed since the current day started. For the starting time, that number is . For the ending time, we use the same expression, except if the ending time is earlier than the starting time. In that case, the ending time is actually the next day, so we need to add seconds.
Subtracting the two numbers we get the number of seconds between the two times. This needs to be converted into hours, minutes and seconds.
Also note the case when the given times are equal. The task description says that 24 hours should be output, not 0.
Comments