#K51677. Library Queries

    ID: 29141 Type: Default 1000ms 256MiB

Library Queries

Library Queries

You are given a collection of books. Each book has a title, an author, and a number of pages. Your task is to answer several queries regarding these books.

The queries are defined as follows:

  • Query 1: Find the book with the maximum number of pages and print its title and author.
  • Query 2: Find the book with the minimum number of pages and print its title and author.
  • Query 3: Calculate the average number of pages of all books, using integer division. That is, compute \(\lfloor \frac{\text{sum of pages}}{n} \rfloor\), where \(n\) is the number of books.

Input is provided via standard input and output must be written to standard output.

inputFormat

The input format is as follows:

  1. An integer \(n\) representing the number of books.
  2. Then \(n\) lines follow, each containing three values: the title (a string), the author (a string), and the pages (an integer) for that book. The values are separated by spaces.
  3. An integer \(q\) representing the number of queries.
  4. A single line with \(q\) integers separated by spaces, where each integer is either 1, 2, or 3 corresponding to the query types described above.

Read from standard input.

outputFormat

For each query, output the result on a new line:

  • For Query 1, print the title and author of the book with the maximum pages.
  • For Query 2, print the title and author of the book with the minimum pages.
  • For Query 3, print the average number of pages (using integer division).

Write the output to standard output.

## sample
3
The_Great_Gatsby F_Scott_Fitzgerald 180
1984 George_Orwell 328
To_Kill_a_Mockingbird Harper_Lee 281
3
1 2 3
1984 George_Orwell

The_Great_Gatsby F_Scott_Fitzgerald 263

</p>