Bear Hunt
Output: Standard Output (stdout)
Memory limit: 256 megabytes
Time limit: 1.0 seconds
During COVID-19 Alert Level 4, the Guardian, an esteemed newspaper in Great Britain, reported on a different entity that went viral in New Zealand... that of the great (teddy) bear hunt!
You decide to go teddy bear hunting. Along the way you spot N bears. Given the time taken between finding each bear, your job is to report the total duration of your hunt.
Input
The first line will contain a single integer, N, the number of bears spotted (1 \le N \le 1000).
Then follows N lines, each containing a single integer T (1 \le T \le 1000). This indicates that a bear was spotted at an elapsed time of T minutes since the last bear was spotted (or for the first bear, since starting the hunt).
It is guaranteed that the total duration of the hunt will be less than 24 hours.
Output
Print a single line containing the total duration of the hunt in the following format: It took {h} hour(s) and {m} minute(s)
, where the number of hours is maximised (i.e. minutes must be less than 60).
The output should be grammatically correct. That is, do not print the 's'
if there is only 1 hour or 1 minute, and don't print hours if there are none. Similarly, don't print minutes if there are none. See the sample cases for examples.
Subtasks
- Subtask 1 (40%): It is guaranteed that the total duration of the hunt will be less than 1 hour.
- Subtask 2 (60%): It is guaranteed that the total duration of the hunt will be less than 24 hours.
Note that only sample case 1 is a valid case for subtask 1. Sample cases 2 and 3 both correspond to subtask 2.
-
Sample Input 1
3 19 10 20
Sample Output 1
It took 49 minutes
-
Sample Input 2
2 45 15
Sample Output 2
It took 1 hour
-
Sample Input 3
4 24 17 42 38
Sample Output 3
It took 2 hours and 1 minute