103680: [Atcoder]ABC368 A - Cut

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:5 Solved:0

Description

Score : $100$ points

Problem Statement

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

You take $K$ cards from the bottom of the stack and place them on top of the stack, maintaining their order.

Print the integers written on the cards from top to bottom after the operation.

Constraints

  • $1 \leq K < N \leq 100$
  • $1 \leq A_i \leq 100$
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

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

Output

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


Sample Input 1

5 3
1 2 3 4 5

Sample Output 1

3 4 5 1 2

Initially, the integers written on the cards are $1,2,3,4,5$ from top to bottom.

After taking three cards from the bottom of the stack and placing them on top, the integers written on the cards become $3,4,5,1,2$ from top to bottom.


Sample Input 2

6 2
1 2 1 2 1 2

Sample Output 2

1 2 1 2 1 2

The integers written on the cards are not necessarily distinct.

Output

得分:100分

问题陈述

有一叠共N张卡片,从顶部数起的第i张卡片上写有一个整数A_i。

你从卡片堆的底部取出K张卡片,并将它们按原顺序放在卡片堆的顶部。

打印操作后从顶部到底部卡片上写有的整数。

约束条件

  • $1 \leq K < N \leq 100$
  • $1 \leq A_i \leq 100$
  • 所有输入值都是整数。

输入

输入从标准输入以以下格式给出:

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

输出

设$B_i$为操作后从卡片堆顶部数起的第i张卡片上写有的整数。按顺序打印$B_1,B_2,\ldots,B_N$,用空格分隔。


示例输入1

5 3
1 2 3 4 5

示例输出1

3 4 5 1 2

最初,卡片上从顶部到底部写有的整数是$1,2,3,4,5$。

从卡片堆底部取出三张卡片并将它们放在顶部后,卡片上从顶部到底部写有的整数变为$3,4,5,1,2$。


示例输入2

6 2
1 2 1 2 1 2

示例输出2

1 2 1 2 1 2

卡片上写有的整数不一定是唯一的。

加入题单

上一题 下一题 算法标签: