#C851. Move k Elements to End of Array

    ID: 52500 Type: Default 1000ms 256MiB

Move k Elements to End of Array

Move k Elements to End of Array

Given an array \(A\) of \(n\) integers and an integer \(k\), your task is to move the first \(k\) elements of the array to its end. The order of the moved and remaining elements should be preserved.

If \(k \le 0\) or \(k \ge n\), the array remains unchanged.

For example, given \(A = [1, 2, 3, 4, 5, 6, 7]\) and \(k = 3\), the output should be \([4, 5, 6, 7, 1, 2, 3]\).

inputFormat

The input is read from stdin and consists of two lines:

  • The first line contains two integers \(n\) and \(k\), where \(n\) is the number of elements in the array and \(k\) is the number of elements to move from the beginning to the end.
  • The second line contains \(n\) space-separated integers representing the array \(A\).

outputFormat

Output the modified array as a sequence of space-separated integers on a single line to stdout.

## sample
7 3
1 2 3 4 5 6 7
4 5 6 7 1 2 3