#K95207. Calculate Final Bills

    ID: 38812 Type: Default 1000ms 256MiB

Calculate Final Bills

Calculate Final Bills

You are given the bills of several customers along with their loyalty status. For each customer, if the bill amount is greater than a threshold \(k\), a primary discount of \(d_1\)% is applied. Furthermore, if the customer is a loyalty member, an additional loyalty discount of \(d_2\)% is applied to the resulting amount. All computations should be done using the following formulas:

If \(b > k\):

\[ \text{bill} = b \times \left(1 - \frac{d_1}{100}\right) \]

If the customer is loyal (flag equals 1):

\[ \text{bill} = \text{bill} \times \left(1 - \frac{d_2}{100}\right) \]

Each final bill amount should be rounded to two decimal places.

inputFormat

The input is read from STDIN and has the following format:

n k d1 d2
bill1 is_loyal1
bill2 is_loyal2
... 
billn is_loyaln

Where:

  • n is the number of customers.
  • k is the threshold amount for the primary discount.
  • d1 is the primary discount percentage.
  • d2 is the loyalty discount percentage.
  • Each subsequent line contains a floating-point number bill representing the bill amount, and an integer is_loyal (either 0 or 1) indicating the loyalty status.

outputFormat

For each customer, output the final bill amount on a separate line to STDOUT, rounded to two decimal places.

## sample
1 100 10 0
120.00 0
108.00

</p>