P26045 [AtCoder] [ABC368A] Cut
入门
题目描述

Problem Description

There is a pile of $ N $ cards, and the $ i $ -th card from the top has an integer $ A_i $ written on it.

We take the $ K $ cards from the bottom of the pile and place them on top of the pile while maintaining their order.

Output the integers written on the cards from the top of the pile after this operation.

Input Format

The input is given from the standard input in the following format:

$ N $ $ K $ $ A_1 $ $ A_2 $ $\ldots$ $ A_N $

Output Format

Let $ B_i $ be the integer written on the $ i $ -th card from the top of the pile after the operation. Output $B_1, B_2, \ldots, B_N$ in this order, separated by spaces.

Sample Input and Output

Sample Input #1

5 3
1 2 3 4 5

Sample Output #1

3 4 5 1 2

Sample Input #2

6 2
1 2 1 2 1 2

Sample Output #2

1 2 1 2 1 2

Notes/Hints

Constraints

  • $1 \leq K < N \leq 100$
  • $1 \leq A_i \leq 100$
  • All inputs are integers

Sample Explanation 1

Initially, the integers written on the cards from the top are $ 1, 2, 3, 4, 5 $. After taking the 3 cards from the bottom and placing them on top, the integers written on the cards from the top are $ 3, 4, 5, 1, 2 $.

Sample Explanation 2

The integers written on the cards are not necessarily distinct.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
5 3 1 2 3 4 5
样例输出
3 4 5 1 2