You are given the current time $$R$$ in the $$HH:MM:SS$$ format. You are also given $$N$$ more time values in an array $$P$$, where every element $$P[i]$$ is less than or equal to $$R$$.
Write a program to calculate the time difference between $$P[i]$$ and $$R$$ and print one of the following messages accordingly:
- If the time difference is zero, print now.
- If the time difference is in seconds but less than a minute, print $$X$$ seconds ago.
- If the time difference is in minutes but less than an hour, print $$X$$ minutes ago. Ignore the seconds part of the difference.
- If the time difference is in hours, print $$X$$ hours ago. Ignore the minutes and seconds part of the difference.
- If the value of $$X$$ is 1, print the word second instead of seconds, hour instead of hours and minute instead of minutes.
Input format
- First line: $$R$$ (In the $$HH:MM:SS$$ format)
- Second line: $$N$$
- Next $$N$$ lines: $$P[i]$$ (In the $$HH:MM:SS$$ format, where \( 0 \le i \lt N \))
Output format
For each $$P[i]$$, print the message indicating the time difference.
Constraints
\( 0 \le HH \le 23 \)
\( 0 \le MM \le 59 \)
\( 0 \le SS \le 59 \)
\( 1 \le N \le 1000 \)
23:05:38 7 23:05:38 23:05:02 23:04:59 23:04:31 12:36:07 08:59:01 00:00:00
now 36 seconds ago 39 seconds ago 1 minute ago 10 hours ago 14 hours ago 23 hours ago
$$R$$ = 23:05:38
Now for each \(P[i]\):
\(R - P[0] \Rightarrow \) 23:05:38 - 23:05:38
\(\Rightarrow\) 00:00:00
. Time difference is zero. Hence the answer is "now".
\(R - P[1] \Rightarrow \) 23:05:38 - 23:05:02
\(\Rightarrow\) 00:00:36
. Time difference is 36 seconds. Hence the answer is "36 seconds ago".
\(R - P[2] \Rightarrow \) 23:05:38 - 23:04:59
\(\Rightarrow\) 00:00:39
. Time difference is 39 seconds. Hence the answer is "39 seconds ago".
\(R - P[3] \Rightarrow \) 23:05:38 - 23:04:31
\(\Rightarrow\) 00:01:07
. Time difference is 1 min 7 seconds. According the rules, when time difference is in minutes but less than an hour, we ignore the seconds part of the difference. Hence the answer is "1 minute ago".
\(R - P[4] \Rightarrow \) 23:05:38 - 12:36:07
\(\Rightarrow\) 10:29:31
. Time difference is 10 hours 29 mins 31 seconds. According the rules, when time difference is in hours, we ignore the minutes and seconds part of the difference. Hence the answer is "10 hours ago".
\(R - P[5] \Rightarrow \) 23:05:38 - 08:59:01
\(\Rightarrow\) 14:06:37
. Time difference is 14 hours 6 mins 37 seconds. According the rules, when time difference is in hours, we ignore the minutes and seconds part of the difference. Hence the answer is "14 hours ago".
\(R - P[6] \Rightarrow \) 23:05:38 - 00:00:00
\(\Rightarrow\) 23:05:38
. Time difference is 23 hours 5 mins 38 seconds. According the rules, when time difference is in hours, we ignore the minutes and seconds part of the difference. Hence the answer is "23 hours ago".
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor