#C12224. Repeat Elements

    ID: 41628 Type: Default 1000ms 256MiB

Repeat Elements

Repeat Elements

You are given a list of integers and an integer ( k ). Your task is to generate a new list in which each element from the input list is repeated consecutively ( k ) times. If ( k ) is less than or equal to 0, the output should be an empty list.

For example, if the input list is [1, 2, 3] and ( k = 3 ), the output should be [1, 1, 1, 2, 2, 2, 3, 3, 3].

inputFormat

Input Format:
The first line contains an integer ( n ), representing the number of elements in the list.
The second line contains ( n ) space-separated integers denoting the list.
The third line contains an integer ( k ), the number of repetitions for each element.

outputFormat

Output Format:
Print the resulting list after repeating each element ( k ) times consecutively. The elements should be printed in a single line separated by a space. If the resulting list is empty, print an empty line.## sample

3
1 2 3
3
1 1 1 2 2 2 3 3 3