#C12428. Repeat Items
Repeat Items
Repeat Items
You are given a list of items with their corresponding quantities. Your task is to output each item repeated as many times as its quantity, preserving the order of appearance from the input. If the quantity is 0, that item should be skipped. The output should be printed as a single line of space‐separated items.
For example, if the input is:
3 apple 2 banana 3 cherry 1
Then the correct output is:
apple apple banana banana banana cherry
inputFormat
The first line contains an integer N
representing the number of items in the dictionary. Each of the next N
lines contains an item (a string without spaces) and an integer quantity separated by a space.
It is guaranteed that N \ge 0
. When N
is 0
, there will be no additional lines.
outputFormat
Print a single line containing the repeated items separated by a single space. There should be no extra spaces at the beginning or end. If there are no items to print, output an empty line.
## sample3
apple 2
banana 3
cherry 1
apple apple banana banana banana cherry