Type: Default 1000ms 64MiB

摆书

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

image

样例输入

2

4

4 1 2 3

5

1 2 3 4 5

样例输出

3

0

样例解释

对于第一组数据,我们先把 3 号书放到最上面,接着操作 2 号书,最后操

作 1 号书,(4, 1, 2, 3) → (3, 4, 1, 2) → (2, 3, 4, 1) → (1, 2, 3, 4), 这样就有序了

对于第二组数据,这摞书本来就有序了,所以不需要任何操作

数据范围及约定

存在 50% 的数据,n ≤ 10

另外存在 30% 的数据,n ≤ 1000

对于 100% 的数据,n ≤ 100000

20240508练习赛

Not Attended
Status
Done
Rule
OI
Problem
4
Start at
2024-5-8 16:00
End at
2024-5-8 20:30
Duration
4.5 hour(s)
Host
Partic.
13