CF1802A.Likes

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Nikita recently held a very controversial round, after which his contribution changed very quickly.

The announcement hung on the main page for nn seconds. In the iith second ∣ai∣|a_i|th person either liked or removed the like (Nikita was lucky in this task and there are no dislikes). If ai>0a_i \gt 0, then the aia_ith person put a like. If ai<0a_i \lt 0, then the person −ai-a_i 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 a1,a2,…,ana_1, a_2, \ldots, a_n. But due to the imperfection of the platform, the sequence aa was shuffled.

You are given a shuffled sequence of aa that describes user activity. You need to tell for each moment from 11 to nn what the maximum and minimum number of likes could be on the post at that moment.

尼基塔最近举办了一场极具争议的比赛,赛后他的贡献值发生了剧烈变化。

公告在主页上持续了 nn 秒。在第 ii 秒,第 ∣ai∣|a_i| 个人要么点赞,要么取消点赞(本题中尼基塔运气很好,不存在“点踩”操作)。若 ai>0a_i > 0,则第 aia_i 个人进行了点赞;若 ai<0a_i < 0,则第 −ai-a_i 个人取消了点赞。每个人至多点赞一次、也至多取消点赞一次;且一个人只有在先前点过赞的前提下,才能取消点赞。

由于该比赛结束后尼基塔的贡献值变得非常糟糕,他希望分析公告在主页展示期间其贡献值的变化情况。他向平台开发者请求提供原始序列 a1,a2,…,ana_1, a_2, \ldots, a_n。但由于平台存在缺陷,所获得的序列 aa 已被随机打乱。

你将得到一个被打乱后的序列 aa,它描述了用户的全部操作行为。你需要对从第 11 秒到第 nn 秒的每一时刻,分别给出此时帖子上可能达到的最多和最少点赞数。

输入格式

The first line of input data contains one number tt (1⩽t⩽10001 \leqslant t \leqslant 1000) — the number of test cases.

In the first line of test case, one number is given nn (1⩽n⩽1001 \leqslant n \leqslant 100) — the number of seconds during which Nikita's announcement hung on the main page.

The next line contains nn numbers b1,b2,b3,…,bnb_1, b_2, b_3, \ldots, b_n (1⩽∣bi∣⩽n1 \leqslant |b_i| \leqslant n) — mixed array aa. It is guaranteed that there exists such a permutation of bb that it is a correct sequence of events described in the condition.

It is guaranteed that the sum of nn for all input test cases does not exceed 10410^4.

输入数据的第一行包含一个整数 tt(1⩽t⩽10001 \leqslant t \leqslant 1000)—— 测试用例的数量。

每个测试用例的第一行包含一个整数 nn(1⩽n⩽1001 \leqslant n \leqslant 100)—— 尼基塔的公告在主页上显示的秒数。

接下来的一行包含 nn 个整数 b1,b2,b3,…,bnb_1, b_2, b_3, \ldots, b_n(1⩽∣bi∣⩽n1 \leqslant |b_i| \leqslant n)—— 混合数组 aa。题目保证存在 bb 的某种排列,使其成为题面描述中所要求的合法事件序列。

保证所有测试用例的 nn 值之和不超过 10410^4。

输出格式

For each test case, output two lines, each of which contains nn numbers.

In the first line, for each test case, output the maximum number of likes that Nikita could have at the announcement at the iith second.

In the second line, for each test case, output the minimum number of likes that Nikita could have at the announcement at the iith second.

对于每个测试用例,输出两行,每行包含 nn 个数字。

第一行:对于每个测试用例,输出 Nikita 在第 ii 秒的公告上可能获得的最大点赞数。

第二行:对于每个测试用例,输出 Nikita 在第 ii 秒的公告上可能获得的最小点赞数。

输入输出样例

  • 输入#1

    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

    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

说明/提示

In the first test case, the maximum values are reached with the following permutation: 1,2,−21, 2, -2. And the minimum values for such: 2,−2,12, -2, 1.

In the third test case, all maximal values are reached with the following permutation: 4,2,3,1,−1,−24, 2, 3, 1, -1, -2. And the minimum values for the next permutation: 2,−2,1,−1,3,42, -2, 1, -1, 3, 4.

在第一个测试用例中,最大值通过以下排列达到:1,2,−21, 2, -2;而最小值则通过如下排列达到:2,−2,12, -2, 1。

在第三个测试用例中,所有最大值均通过以下排列达到:4,2,3,1,−1,−24, 2, 3, 1, -1, -2;而最小值则通过下一个排列达到:2,−2,1,−1,3,42, -2, 1, -1, 3, 4。

输入解题思路,AI测评打分。不知道怎么写?

首页