DWITE Online Computer Programming Contest

Travel Time

February 2013
Problem 1

Travelling can be very tiresome. One of the most annoying aspects of travelling is adjusting your watch to the appropriate time after reaching the destination. Being an avid traveller yourself, you decide to write a program to help you determine the local time at the time of arrival.

The input file DATA1.txt will contain 5 test cases. Each test case consists of two lines. First is a timestamp T in 24-hour format, e.g. 13:59:05. The second line is a space-separated pair of numbers −24 ≤ N, H ≤ 24, which are the number of hours the journey takes and the number of hours the destination time zone is ahead of the origin time zone. (Negative time ahead is interpreted as “behind”; similarly, negative travel time is calculating the time before the journey started.)

The output file OUT1.txt will contain 5 lines of output: the 24-hour timestamps of the expected local time at the destination.

Sample Input (first 4 cases shown):
03:01:01 10 0
03:02:02 10 5
03:03:03 10 -23
00:00:00 0 0
Sample Output (first 4 cases shown):

Notes on the sample data: The first case starts out at 3 AM. After 10 hours it is now 1 PM; there is no time zone adjustment. The second case is similar, but the destination time zone is 5 hours ahead, so it’s 6 PM. The third case is 2 PM... of the previous day. Case 4 starts at midnight, and you are not going anywhere.