#C7441. Minimum Price After Discounts

    ID: 51313 Type: Default 1000ms 256MiB

Minimum Price After Discounts

Minimum Price After Discounts

You are given an initial price \(p\) of an item, a number \(k\) of discount coupons, and a list of \(k\) discount percentages. Your task is to calculate the minimum possible price after applying all the discount coupons optimally.

The discounts should be applied sequentially in descending order. This means you first apply the coupon with the highest discount percentage, then the next highest, and so on. Mathematically, if the discounts (in percentage) after sorting in descending order are \(d_1, d_2, \dots, d_k\), the final price \(P_f\) is computed as:

[ P_f = p \times \prod_{i=1}^{k} \left( 1 - \frac{d_i}{100} \right), ]

Round the final price to two decimal places.

inputFormat

The input is provided via stdin in the following format:

p k
[discount1 discount2 ... discountk]

Where:

  • p is a floating-point number representing the initial price.
  • k is an integer denoting the number of discount coupons.
  • If k > 0, the next line contains k integers separated by spaces, each representing a discount percentage.

outputFormat

Output the final price after applying the discounts sequentially (in descending order) to stdout. The result must be a floating-point number rounded to two decimal places.

## sample
100.00 3
20 30 50
28.00