DWITE '12 R5 #1 - Travel Time

View as PDF

Submit solution

Points: 3
Time limit: 2.0s
Memory limit: 64M

Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig
DWITE, 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 will contain 5 test cases. Each test case consists of one line containing a timestamp T (in a 24-hour clock, e.g. 13:59:05) and a space separated pair of numbers -24 \le N, H \le 24. N is the number of hours the journey takes, and H is the number of hours the destination timezone is ahead of the origin timezone (negative time ahead is interpreted as "behind"; similarly, negative travel time is calculating the time before the journey started).

The output will contain 5 lines of output. The 24-hour timestamp of the expected local time at the destination.

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

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)

13:01:01
18:02:02
14:03:03
00:00:00

Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0) Problem Resource: DWITE


Comments

There are no comments at the moment.