The Broken Clock
Medium
math
time-calculation
logic
Problem Description
A broken clock shows the wrong time and gains or loses a fixed number of minutes every hour. Given the current wrong time displayed, the rate of gain/loss per hour, and the number of hours that have passed, determine what the real current time should be.
Input Format
Three lines: 1) Wrong time in HH:MM format (24-hour), 2) Minutes gained/lost per hour (positive for gain, negative for loss), 3) Number of hours passed.
Output Format
The real current time in HH:MM format (24-hour).
Constraints
• Time format: 00:00 to 23:59
• -60 ≤ gain/loss per hour ≤ 60
• 0 ≤ hours passed ≤ 1000
• Handle day overflow (24-hour cycle)
• Round minutes to nearest integer
Sample Input/Output
Input:
12:30 5 2
Output:
12:20
Explanation
The clock shows 12:30 and gains 5 minutes per hour. After 2 hours, it gained 10 minutes total. So the real time is 12:30 - 10 minutes = 12:20.
Solution Hints
90
Points
Points
2000ms
Time Limit
Time Limit
128MB
Memory Limit
Memory Limit
Code Editor
Register to Access Code Editor
Create a free account to solve coding problems and track your progress.
Register Now