Hide

# Problem ISimple Cron Spec

A Cron Spec is used by Linux to specify when to repeatedly execute a certain job. For this problem, consider a Simple Cron Spec that defines when a job needs to be run within a single day. A Simple Cron Spec has three space separated tokens:

$hours$ $minutes$ $seconds$

that specify at which hours/minutes/seconds a job will be run. Hour values are $0$-$23$, minute and second values are $0$-$59$.

Each token consists of a single integer value, a value range (two values separated by a dash ‘-’), a comma-separated list of multiple values and/or value ranges, or an asterisk (‘*’). A value range represents all integer values between the low and high value, inclusive. An asterisk is a special token that represents all possible values. The specified values in any comma separated list must be non-overlapping.

For example, the specification:

* 30 20,25,30-33

says the job will be run every hour, at minute $30$, and second $20$, $25$, $30$, $31$, $32$, and $33$, for a total of $24 \times 1 \times 6 = 144$ times each day.

Given a list of Simple Cron Specs, determine two things: First, the number of seconds in the day that at least one job will start, and second, the total number of job starts during the day. Note that if a single job starts 24 times in a day, that counts as 24 job starts.

## Input

The first line of input contains a single integer $n$ ($1 \le n \le 100$), which is the number of Simple Cron Specs that follow.

Each of the next $n$ lines contains three strings $h$, $m$ and $s$. These are the hours, minutes, and seconds specifications of the Simple Cron Specs. Each $h$, $m$ and $s$ consists of either a single star (‘*’), or a comma-separated list of one or more values or value ranges (two values separated by ‘-’). The values/ranges are guaranteed to be within the appropriate limits ($0$ to $23$ for hours, $0$ to $59$ for minutes and seconds), and are guaranteed to not overlap. All range specifications are guaranteed to consist of two distinct values, smallest first. All values specified in a comma-separated list are guaranteed to be in strictly increasing order. The whole is guaranteed to be a legitimate Simple Cron Spec. The only spaces in the line will be a single space between $h$ and $m$, and a single space between $m$ and $s$.

## Output

Output two space separated integers. The first is the number of seconds in the $24$ hour day with at least one job start, and the second is the total number of job starts.

Sample Input 1 Sample Output 1
2
* 30 20,25,30-33
9,15 30 *

252 264


Please log in to submit a solution to this problem
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 1, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.3098125159740448, "perplexity": 826.8633714851716}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.3, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2023-14/segments/1679296949701.56/warc/CC-MAIN-20230401063607-20230401093607-00633.warc.gz"}