#K86742. Order Total Calculation and Discount Qualification
Order Total Calculation and Discount Qualification
Order Total Calculation and Discount Qualification
In this problem, you are given a series of orders. Each order consists of several items. For each order, you will calculate the total price using the formula \(T = \sum_{j=1}^{k} x_j \cdot p_j\), where \(k\) is the number of items in the order, \(x_j\) is the quantity of the \(j^{th}\) item and \(p_j\) is its price.
An order qualifies for a discount if its total price is strictly greater than a given threshold \(t\). If no order qualifies, output -1 for the discount qualification list.
Your task is to compute:
- A list of total prices for each order.
- A list of the 1-based indices of orders that qualify for a discount (or -1 if none qualify).
inputFormat
The input is given via standard input. The first line contains two integers \(n\) and \(t\) where \(n\) is the number of orders and \(t\) is the discount threshold.
Then \(n\) lines follow. Each order is described in one line starting with an integer \(k\) representing the number of items in the order, followed by \(2 \times k\) integers. Each pair of integers corresponds to \(x_j\) (the quantity) and \(p_j\) (the price) of an item.
outputFormat
Output two lines. The first line contains the total price of each order, separated by a single space. The second line contains the 1-based indices of orders that qualify for a discount, separated by a single space. If no order qualifies, output a single -1.
## sample3 500
2 3 200 5 100
1 10 20
3 2 150 1 300 4 50
1100 200 800
1 3
</p>