#K82592. Spells and Discounts Calculation
Spells and Discounts Calculation
Spells and Discounts Calculation
You are given a list of spells each with a base cost. Each spell is represented by an uppercase letter starting from 'A'. You are also provided with a sequence that indicates which spells are cast. Additionally, there are some discounts provided that reduce the cost of specific spells by a given percentage. The discount is applied to the base cost using the formula: \( c' = c \times \bigl(1 - \frac{p}{100}\bigr) \), where \( c \) is the original cost and \( p \) is the discount percentage.
Your task is to compute the total cost for casting the spells in the given sequence after applying all the provided discounts. The final answer should be rounded to the nearest integer.
inputFormat
The input is provided via standard input (stdin) and has the following format:
- An integer \( n \) representing the number of spells (each spell is represented by a letter starting from 'A').
- \( n \) space-separated integers representing the cost of each spell.
- A string representing the sequence of spells cast.
- An integer \( d \) representing the number of discounts.
- Then \( d \) lines follow, each containing a character (the spell) and an integer (the discount percentage) separated by a space.
outputFormat
Output a single integer — the total cost for casting the spells after applying all discounts, rounded to the nearest integer. The output should be printed to standard output (stdout).
## sample3
10 20 30
ABAC
2
A 20
C 50
51