#K49702. Discounted Checkout Total Calculation
Discounted Checkout Total Calculation
Discounted Checkout Total Calculation
You are given a list of item prices and a list of indices representing the items purchased from a store. Your task is to calculate the total amount to be paid after applying a discount to the highest priced item among those purchased. The discount is 20% of the maximum price among the chosen items, i.e., \(discount = 0.2 \times \max_{i \in S} price_i\), where \(S\) is the set of purchased items. If no items are purchased, the total amount is \(0.0\).
inputFormat
The input is read from stdin and consists of four parts:
- An integer \(N\) representing the number of items in the store.
- \(N\) space-separated floating-point numbers representing the prices of each item.
- An integer \(M\) representing the number of items purchased.
- If \(M > 0\), then \(M\) space-separated integers follow, each representing a 0-indexed position of a purchased item.
outputFormat
Output a single floating-point number to stdout representing the total cost after applying the discount on the highest priced purchased item. The result should be computed with double precision.
## sample3
10.0 20.0 30.0
3
0 1 2
54.0