#C3644. Order Revenue and Distinct Price Calculation

    ID: 47094 Type: Default 1000ms 256MiB

Order Revenue and Distinct Price Calculation

Order Revenue and Distinct Price Calculation

You are given a list of orders, where each order describes a set of items. Each item is represented by a pair of integers: its quantity and its price. Your task is to calculate two values:

  1. The total revenue which is calculated as the sum of (quantity × price) for all items in all orders.
  2. The number of distinct item prices (each unique price is treated as a unique item), regardless of how many times they appear.

These calculations can be formalized as follows:

(\text{Total Revenue} = \sum_{order \in orders} \sum_{(q, p) \in order} q \times p)

(\text{Distinct Items} = \left| {p : p \text{ appears in any order} } \right|)

Input and output should be handled via standard input (stdin) and standard output (stdout).

inputFormat

The first line of input contains a single integer (T), the number of orders. For each order, the first integer (K) denotes the number of items in that order, followed by (2K) integers representing the quantity and price for each item.

outputFormat

Output two integers separated by a space: the total revenue and the number of distinct item prices.## sample

0
0 0