Pre-check time
Statement
A broadcasting station is on air 24 hours a day without a break. When a live show is scheduled, an engineer checks the transmission equipment 45 minutes before that time. The check takes exactly 45 minutes, so the live show starts the moment the check is done.
The clock the engineer uses writes the day from 0 hours 0 minutes to 23 hours 59 minutes, and it does not write the date. So when moving 45 minutes back from the time of the show goes earlier than 0 hours 0 minutes, the check time falls on the previous day. Even then the date is not written, only the hour and the minute.
Write a program that prints the pre-check time when the time of the live show is given.
For example, suppose the live show is at 10 hours 10 minutes. You cannot take 45 minutes straight out of 10 minutes, so you have to borrow one hour and turn it into minutes. That is, 10 hours 10 minutes is the same as 9 hours 70 minutes, and taking 45 minutes out of that leaves 9 hours 25 minutes. Writing the steps along the way as a table gives the following.
| Step | Hour | Minute |
|---|---|---|
| Time of the live show | 10 | 10 |
| After borrowing one hour as minutes | 9 | 70 |
| After taking 45 minutes out | 9 | 25 |
So the check time in this case is 9 hours 25 minutes.
Now suppose the live show is at 0 hours 0 minutes. There is no hour to borrow, so the time rolls over to 23 hours, and 45 minutes before 0 hours 0 minutes is 23 hours 15 minutes on the previous day. Putting other cases into one table gives the following.
| Time of the live show | 10 hours 10 minutes | 0 hours 0 minutes | 0 hours 45 minutes | 23 hours 59 minutes |
|---|---|---|---|---|
| Check time | 9 hours 25 minutes | 23 hours 15 minutes | 0 hours 0 minutes | 23 hours 14 minutes |
When the minute is 45 or more, the hour stays as it is and you only take 45 out of the minute. That is what happens when 0 hours 45 minutes becomes 0 hours 0 minutes.
Input and output examples
Example 1
Input
10 10
Output
9 25
Example 2
Input
0 0
Output
23 15
Example 3
Input
0 45
Output
0 0
Input
First the hour H and the minute M of the live show are given on the first line, in that order, separated by one space. H is an integer from 0 to 23, and M is an integer from 0 to 59. That is, anything from 0 0 up to 23 59 can come in. The hour and the minute are given with no leading zero attached. Values such as the date or the day of the week are not given. This one line is the only line of input, and the space between the two numbers is a single space.
Output
Print the hour and the minute of the pre-check time on the first line, in that order, separated by one space. Write the hour and the minute as the numbers themselves, with no leading zero attached. For 0 hours 15 minutes you print 0 15. The space between the two numbers is a single space, and no space is attached after the minute.
Requirements
- The input is one line, and it holds two numbers separated by one space
- H is an integer from 0 to 23, and M is an integer from 0 to 59
- When the time goes earlier than 0 hours 0 minutes, it rolls back to the previous day
- Print the hour and the minute on one line, separated by one space
- Do not attach a leading zero to the hour or to the minute
- You must write a program that reads from standard input and writes to standard output
- Trailing spaces at the end of a line and blank lines at the end of the output are ignored when grading
- The languages you can use are Python and JavaScript
- The memory limit is 256MB. The browser does not measure it, it only states it
- The time limit is set by measuring the setter's reference solution on the same runtime
- On this problem you submit code, not a prompt. That code runs in the browser on this device, and all that goes to the server is a fingerprint of the output and the time it took. Whether it is correct is decided by the server. The run time is a number each device reports, so the code and the device details are posted next to it on the leaderboard.
- The output has to match the expected value down to the character. A space inside a line counts the same as any other character.
- There are 15 cases, and 3 of them show the input together with the expected output. The rest are used only when you submit and are not shown on this page.
- You have to pass all 15 cases to solve this.
Examples
3 public cases. Judging also uses hidden cases. You have to pass all 15 cases to solve this.
10 10
9 25
0 0
23 15
0 45
0 0
Solution
Your code runs on this device. Only the fingerprint of the output and the elapsed time go to the server. The server decides whether it is correct.
Submitting requires you to log in. Running against the public cases works without one.
You can test with 3 public cases. Submitting runs the hidden cases too.
People who solved this problem
The time shown is the time spent solving. Input reading time is outside the solver's control, so it is excluded. And since each device reports this value itself, we record which device measured it.
Log in and you can see the code once you solve this problem.
Log in and you can see the code once you solve this problem.