#K63922. Assign Discounts to Customers
Assign Discounts to Customers
Assign Discounts to Customers
In this problem, you are given a list of unique discount percentages and a list of customers. Your task is to assign a discount to each customer in order. If there are more customers than available discounts, the remaining customers will receive a discount of 0. The assignment is done sequentially: the first customer gets the first discount, the second gets the second discount, and so on. Formally, if there are (D) discounts and (C) customers, then for every (i) such that (0 \leq i < \min(D, C)), the (i)th customer receives the (i)th discount. Any customer with index (i \geq D) receives 0. This simple allocation will be used to test your understanding of handling inputs, arrays, and conditional assignment.
inputFormat
The input is read from standard input (stdin) and consists of four lines:
- An integer (D), the number of available discount percentages.
- (D) space-separated integers representing the discount percentages.
- An integer (C), the number of customers.
- (C) space-separated strings, each representing a customer's name.
Note: If (D = 0), the second line may be empty.
outputFormat
Output a single line to standard output (stdout) containing (C) space-separated integers. Each integer represents the discount percentage assigned to the corresponding customer, in the order they appear in the input.## sample
3
50 20 30
3
Alice Bob Charlie
50 20 30