``Dynamic'' Inversion

题目描述

[problemUrl]: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=229&page=show_problem&problem=3141 [PDF](https://uva.onlinejudge.org/external/119/p11990.pdf) ![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA11990/b71ec5ebd8beb2b30e521503dc747b432985e49d.png)

输入输出格式

输入格式


![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA11990/14ff83c5754eeea259a3afdef2faa38dc7d7f077.png)

输出格式


![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA11990/2d1a4d05faa8a92fef49bb256c921004fee850d6.png)

输入输出样例

输入样例 #1

5 4
1
5
3
4
2
5
1
4
2

输出样例 #1

5
2
2
1