欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1799A.Recent Actions
Recent Actions
On Codeforces the "Recent Actions" field shows the last posts with recent actions.
Initially, there are posts in the field (this is in order from top to down). Also there are infinitely many posts not in the field, numbered with integers .
When recent action happens in the post :
- If it is in the "Recent Actions" field, it moves from its position to the top position.
- Otherwise, it is added to the top position, and the post on the down position is removed from the "Recent Actions" field.
You know, that the next recent actions will happen in the posts () in the moments of time . Note, that recent actions only happen with posts with numbers .
For each post (), find the first time it will be removed from the "Recent Actions" field or say, that it won't be removed.
Input
The first line contains a single integer () — the number of test cases. Descriptions of test cases follow.
The first line of each test case contains two integers , () — the size of the "Recent Actions" field and the number of actions.
The next line contains integers ().
It is guaranteed, that the sum of and the sum of for all test cases does not exceed .
Output
For each test case print integers , where if the post won't be removed or equals to the first moment of time the post will be removed ().
Note
In the first test case, the only post will be removed at the moment and replaced by the post .
In the second test case the "Recent Actions" field will be (given an order from top to down):
- Before moment : , after moment : . Post number was removed.
- Before moment : , after moment : . Post number was removed.
Post number won't be removed.
In the third test case the "Recent Actions" field will be (given an order from top to down):
- Before moment : , after moment : . Post number was removed.
- Before moment : , after moment : . Post number was removed.
- Before moment : , after moment : . Nothing was changed.
- Before moment : , after moment : . The order was changed.
- Before moment : , after moment : . Post number was removed.
Post number won't be removed.
Samples
10
1 1
2
3 2
5 4
4 5
5 9 9 5 7
5 5
6 7 8 9 10
3 4
4 4 4 4
4 4
5 5 6 6
3 5
4 5 5 5 4
4 20
5 5 24 24 24 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20
5 7
7 8 7 11 7 12 10
6 7
8 11 7 8 8 8 12
1
-1 2 1
-1 5 2 1
5 4 3 2 1
-1 -1 1
-1 -1 3 1
-1 2 1
8 7 3 1
7 6 4 2 1
-1 -1 7 3 2 1
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |