#K62742. Calculate Discounted Total Cost of Books
Calculate Discounted Total Cost of Books
Calculate Discounted Total Cost of Books
You are given the number of books and their individual prices. Your task is to compute the total cost after applying an appropriate discount based on the number of books purchased.
Discount rules are as follows:
(\text{If } N \geq 6,; \text{discount} = 15%)
(\text{If } 4 \leq N \leq 5,; \text{discount} = 10%)
(\text{If } N \leq 3,; \text{no discount is applied})
The final cost is calculated using the formula:
( \text{Cost} = \left( \sum_{i=1}^{N} p_i \right) \times (1 - d) )
where (d) is the discount rate. The answer should be rounded to two decimal places.
inputFormat
Input is read from standard input (stdin). The first line contains an integer ( N ) (the number of books). The second line contains ( N ) space-separated floating-point numbers, each representing the price of a book.
outputFormat
Output the total cost after applying the discount, rounded to two decimal places. The result is printed to standard output (stdout).## sample
3
100.0 150.0 200.0
450.00