#C7699. Calculate Final Discounted Price
Calculate Final Discounted Price
Calculate Final Discounted Price
You are given a list of items. Each item has a price and a quantity. Your task is to calculate the total price and then apply a discount based on the following rules:
- If the total price \(T\) satisfies \(100 \le T < 200\), then a discount of 10% is applied.
- If \(200 \le T < 500\), then a discount of 20% is applied.
- If \(T \ge 500\), then a discount of 30% is applied.
- If none of the above conditions is met, no discount is applied.
Finally, compute the discounted price using the formula:
\(Final\ Price = \lfloor T \times (1 - discount) \rfloor\)
Note that all percentages should be considered in decimal form (for instance, 10% as 0.10). The input will be provided through standard input (stdin) and your answer should be printed to standard output (stdout).
inputFormat
The first line contains an integer n
representing the number of items. Each of the following n
lines contains two space-separated integers: the price
and quantity
of an item.
outputFormat
Output a single integer which is the final price after applying the discount.
The discount is applied based on the total price \(T\) as follows:
- If \(100 \le T < 200\), discount = 10%.
- If \(200 \le T < 500\), discount = 20%.
- If \(T \ge 500\), discount = 30%.
- Otherwise, discount = 0%.
1
50 1
50