DMOPC '13 Contest 3 P2 - Phone Microwave

View as PDF

Submit solution

Points: 7 (partial)
Time limit: 0.6s
Memory limit: 64M

Author:
Problem type

Recently, you have lost all sense of time, constantly forgetting what year it is. You assume this is due to the fact that you are in possession of the infamous Phone Microwave, which sends text messages to the past — for every second the microwave is set to, the message will go an hour back in time. In a desperate attempt to fix your internal temporal clock (which was ruined by confusing your past self with messages about the future), you decide to send one last message telling you not to acquire the suspicious-looking microwave in the first place. To do so, you need to write a program telling you what time your past self will receive the message, based on the current time and the microwave's settings.

Given the date and setting on the microwave, figure out when your past self will receive the text. The microwave has a maximum time setting of 2 hours and you may assume that you always start between the years 2010 and 2011. The input will be given by the seconds and the time.

Input Specification

The first line of input contains an integer S, the Phone Microwave's time setting, in seconds. This value will not exceed 7\,200 (2 hours).

The second line of input contains the current date, given in this format:

YYYY/MM/DD HH:MM:SS

The year will be one of the years 2010 or 2011, the month will be a valid month from 01 to 12, and the day will be a valid day for that month. Here is a mnemonic to help you remember:

30 days hath September,
April, June and November,
All the rest have 31,
Excepting February alone
(And that has 28 days clear,
With 29 in each leap year).

The hour will be a valid hour from 00 to 23, and the minutes and seconds will each be a valid value ranging from 00 to 59.

Output Specification

You are to output the date when your past self receives the text, in the same format as the input as described in the previous section.

Constraints

Test Case BatchMarksConstraints
1 [3 cases]200 \le S \le 10
Additionally, your past self will receive the text on the same day.
2 [3 cases]300 \le S \le 48
Additionally, your past self will receive the text on the same month.
3 [3 cases]300 \le S \le 7\,200
Additionally, your past self will receive the text on the same year.
4 [3 cases]200 \le S \le 7\,200
No extra constraints.

Sample Input 1

120
2010/07/28 13:00:00

Sample Output 1

2010/07/23 13:00:00

Explanation for Sample Output 1

The Phone Microwave is set to 120 seconds, which takes you back exactly 5 days.

Sample Input 2

2
2011/01/01 01:23:45

Sample Output 2

2010/12/31 23:23:45

Explanation for Sample Output 2

The Phone Microwave takes you back 2 hours, which passes into the previous year.


Comments

There are no comments at the moment.