#C3675. Insect Analysis Challenge

    ID: 47128 Type: Default 1000ms 256MiB

Insect Analysis Challenge

Insect Analysis Challenge

In this problem, you are given information about various insects. Each insect has a species name, an age, and a wing length. You will be required to answer queries about these insects. There are two types of queries:

  • average_age <species>: Calculate the average age of all insects of a given species using the formula \(\text{avg} = \frac{\text{sum of ages}}{\text{number of insects}}\).
  • max_wing_length <age>: Find the maximum wing length among all insects with an age greater than the specified value.

If no insect meets the query criteria, output No data.

inputFormat

The first line contains an integer T, the number of test cases. For each test case, the input format is as follows:

  • The first line contains an integer n — the number of insects.
  • The next n lines each contain three values separated by spaces: a species (string), an age (integer), and a wing length (floating-point number).
  • The following line contains an integer q — the number of queries.
  • The next q lines each contain a query. A query is either in the format average_age <species> or max_wing_length <age>.

outputFormat

For each test case, output exactly q lines. Each line should contain the answer to the corresponding query. If a query cannot be answered because no insects fulfill the condition, output No data (without quotes).

## sample
1
3
bee 2 5.1
ant 4 8.3
bee 3 6.2
2
average_age bee
max_wing_length 2
2.50

8.30

</p>