#K61492. Top Selling Product Analysis
Top Selling Product Analysis
Top Selling Product Analysis
This problem involves analyzing the sales data of a company across several product types. For each dataset, you are given multiple product types and, for each product type, several products along with their unit sales. Your task is to compute the total sales for each product type using the formula \(Total\ Sales = \sum_{i} units_{i}\) and then determine which product type has the highest total sales.
If there is a tie, return the product type that appears first in the dataset.
inputFormat
The input begins with an integer \(T\) representing the number of datasets. For each dataset, the input format is as follows:
- An integer \(N\) that indicates the number of product types in the dataset.
- For each product type:
- A line containing a string, the product type name.
- An integer \(M\) representing the number of products for this product type.
- \(M\) lines each containing two integers separated by a space: a product ID and its corresponding units sold.
outputFormat
For each dataset, output a single line containing the product type with the highest overall sales and its total units sold, separated by a space.
## sample2
3
Electronics
2
101 50
102 75
Furniture
3
201 30
202 55
203 40
Clothing
2
301 45
302 55
2
Grocery
4
401 10
402 20
403 30
404 40
Toys
3
501 25
502 35
503 20
Electronics 125
Grocery 100
</p>