#C14784. Product Price Analyzer

    ID: 44471 Type: Default 1000ms 256MiB

Product Price Analyzer

Product Price Analyzer

This problem involves analyzing the price data of products over a given date range. You are given a start date (\texttt{start_date}) and an end date (\texttt{end_date}) in the format (YYYY\text{-}MM\text{-}DD), along with (n) records. Each record consists of a date, a product name, and its price. Your task is to determine, for each product, the highest price and the average price over the date range. The average price is computed as (\frac{\sum_{i=1}^{n}price_i}{n}). Only those records whose date falls within the inclusive range (\texttt{start_date} \leq \texttt{date} \leq \texttt{end_date}) should be considered.

If a product does not have any data in the given date range, it should not be included in the output. The final output should list each product (sorted in lexicographical order) followed by its highest price and its average price (rounded to one decimal place).

inputFormat

Input is read from standard input. The first line contains two strings: (start_date) and (end_date) separated by a space. The second line contains an integer (n) which represents the number of records. Each of the next (n) lines contains a record with three fields: a date (in YYYY-MM-DD format), a product name (a string without spaces), and a price (an integer). For example:

2023-01-01 2023-01-03 3 2023-01-01 ProductA 100 2023-01-02 ProductA 200 2023-01-03 ProductA 150

outputFormat

For every product that has at least one record within the given date range, output a line containing the product name, its highest price, and its average price (rounded to one decimal place), separated by a space. The products must be printed in lexicographical order by their names. If no record exists for the given range, output nothing.## sample

2023-01-01 2023-01-03
3
2023-01-01 ProductA 100
2023-01-02 ProductA 200
2023-01-03 ProductA 150
ProductA 200 150.0

</p>