#K74062. Categorize Books by Page Count

    ID: 34114 Type: Default 1000ms 256MiB

Categorize Books by Page Count

Categorize Books by Page Count

You are given a list of books, each described by a title, an author, and the number of pages. Your task is to categorize the books into three groups based on their page count:

  • Short Books: Books with fewer than 100 pages.
  • Medium Books: Books with between 100 and 300 pages (inclusive).
  • Long Books: Books with more than 300 pages.

For each category, output the titles in alphabetical order and enclose each title in double quotes. If a category contains no books, output "None" immediately after the category header. Input is read from standard input and output is printed to standard output.

The page ranges should be interpreted mathematically as:

$$\text{Short Books: } pages < 100$$

$$\text{Medium Books: } 100 \le pages \le 300$$

$$\text{Long Books: } pages > 300$$

inputFormat

The first line of input contains an integer n denoting the number of books.

Each of the following n lines contains details of one book in the format:

title, author, pages

Note: The fields are separated by commas. The title and author can contain spaces.

Example:

4
To Kill a Mockingbird, HarperLee, 281
1984, GeorgeOrwell, 328
The Little Prince, AntoineDeSaint-Exupery, 96
Pride and Prejudice, JaneAusten, 279

outputFormat

Print the categorized books in three groups. Each group should start with its category header followed by a colon. Then, if there are any books in that category, print each book title (enclosed in double quotes) on a new line. If a category has no books, print "None" on the following line.

Example output:

Short Books:
"The Little Prince"
Medium Books:
"Pride and Prejudice"
"To Kill a Mockingbird"
Long Books:
"1984"
## sample
4
To Kill a Mockingbird, HarperLee, 281
1984, GeorgeOrwell, 328
The Little Prince, AntoineDeSaint-Exupery, 96
Pride and Prejudice, JaneAusten, 279
Short Books:

"The Little Prince" Medium Books: "Pride and Prejudice" "To Kill a Mockingbird" Long Books: "1984"