#C5333. Calculate Final Prices for Sales
Calculate Final Prices for Sales
Calculate Final Prices for Sales
You are given a list of products, each identified by a unique ID, a category, and a price. In addition, you are provided with a list of categories along with their discount percentages. Finally, a list of sold product IDs is provided. Your task is to compute the final sale price for each product based on its associated discount.
The discount is applied using the formula:
[ final_price = price \times \left(1 - \frac{discount}{100}\right) ]
Round the final price to 2 decimal places. The sale IDs start at 1 and increase in the order the products are sold.
inputFormat
The input is read from standard input (stdin) in the following format:
- The first line contains two integers:
P
(the number of products) andC
(the number of categories). - The next
P
lines each contain three values:product_id
(an integer),category_id
(an integer), andprice
(a floating-point number), separated by spaces. - The next
C
lines each contain two values:category_id
(an integer) anddiscount
(an integer representing the discount percentage) separated by a space. - The next line contains an integer
S
, the number of products sold. - The final line contains
S
integers separated by spaces, representing the soldproduct_id
s in order.
outputFormat
For each sold product, output a line to standard output (stdout) containing two values: the sale ID (starting from 1) and the final price (after discount, rounded to 2 decimal places). The two values should be separated by a space.
## sample1 1
1 1 100
1 10
1
1
1 90.00