欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1802A.Likes
Likes
Nikita recently held a very controversial round, after which his contribution changed very quickly.
The announcement hung on the main page for seconds. In the th second th person either liked or removed the like (Nikita was lucky in this task and there are no dislikes). If , then the th person put a like. If , then the person removed the like. Each person put and removed the like no more than once. A person could not remove a like if he had not put it before.
Since Nikita's contribution became very bad after the round, he wanted to analyze how his contribution changed while the announcement was on the main page. He turned to the creator of the platform with a request to give him the sequence . But due to the imperfection of the platform, the sequence was shuffled.
You are given a shuffled sequence of that describes user activity. You need to tell for each moment from to what the maximum and minimum number of likes could be on the post at that moment.
Input
The first line of input data contains one number () — the number of test cases.
In the first line of test case, one number is given () — the number of seconds during which Nikita's announcement hung on the main page.
The next line contains numbers () — mixed array . It is guaranteed that there exists such a permutation of that it is a correct sequence of events described in the condition.
It is guaranteed that the sum of for all input test cases does not exceed .
Output
For each test case, output two lines, each of which contains numbers.
In the first line, for each test case, output the maximum number of likes that Nikita could have at the announcement at the th second.
In the second line, for each test case, output the minimum number of likes that Nikita could have at the announcement at the th second.
Note
In the first test case, the maximum values are reached with the following permutation: . And the minimum values for such: .
In the third test case, all maximal values are reached with the following permutation: . And the minimum values for the next permutation: .
Samples
5
3
1 2 -2
2
1 -1
6
4 3 -1 2 1 -2
5
4 2 -2 1 3
7
-1 6 -4 3 2 4 1
1 2 1
1 0 1
1 0
1 0
1 2 3 4 3 2
1 0 1 0 1 2
1 2 3 4 3
1 0 1 2 3
1 2 3 4 5 4 3
1 0 1 0 1 2 3
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |