#C14718. Normalize and Filter Product Prices

    ID: 44398 Type: Default 1000ms 256MiB

Normalize and Filter Product Prices

Normalize and Filter Product Prices

You are given a list of product names and their corresponding prices. Your task is to normalize the prices so that the cheapest product has a normalized price of \(1\) (i.e. every price is divided by the minimum price). Then, filter out any products whose normalized price is greater than a specified threshold. Finally, output the remaining product names and their normalized prices.

Normalization Formula: \(\text{normalized price} = \frac{\text{price}}{\min(\text{prices})}\).

Input Constraints:

  • The number of products \(n\) is provided on the first line.
  • The second line contains \(n\) product names separated by spaces.
  • The third line contains \(n\) product prices separated by spaces.
  • The fourth line contains the threshold value (a decimal number).

Output: Print two lines. The first line contains the names of the products that meet the criteria, separated by spaces. The second line contains their corresponding normalized prices rounded to two decimal places, separated by spaces. If no product meets the criteria, output two empty lines.

inputFormat

The input is read from standard input (stdin) and is formatted as follows:

n
name1 name2 ... namen
price1 price2 ... pricen
threshold

where \(n\) is the number of products. The product names and prices are separated by spaces. The threshold is a decimal number.

outputFormat

The output should be written to standard output (stdout) in the following format:

filtered_name1 filtered_name2 ...
normalized_price1 normalized_price2 ...

Each normalized price must be rounded to two decimal places. If no product qualifies, output two empty lines.

## sample
4
laptop phone tablet monitor
1000 500 300 700
2.5
phone tablet monitor

1.67 1.00 2.33

</p>