CF1297C.Dream Team

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

The first line contains one integer tt ( 1t1041 \le t \le 10^4 ) — the number of test cases. Then tt test cases follow.

Each test case begins with a line containing one integer nn ( 2n1052 \le n \le 10^5 ) — the number of developers "on the bench".

The second line of a test case contains a sequence of integers a1,a2,,ana_1, a_2, \dots, a_n ( 104ai104-10^4 \le a_i \le 10^4 ) — the characteristics of the nn developers. It is guaranteed that the characteristics are such that the sum of the characteristics in the answer is strictly positive.

It is guaranteed that the sum of nn over all test cases in the input doesn't exceed 10510^5 .

输入格式

Print the answers for the given tt test cases in the order that they appear in the input. In the first line of each answer, print a positive integer ss — the sum of the characteristics in the desired subset. The second line should contain only the characters 0 and 1 and match the answer:

  • the character in the ii -th position should be equal to 1 if the ii -th developer belongs to the team;
  • the character in the ii -th position should be equal to 0 if the ii -th developer does not belong to the team.

If there are several answers, print any of them.

输出格式

In the first test case, the maximum subset a1,a3,a5a_1, a_3, a_5 has a sum equal to 33 , so Polycarp should choose a team with the maximum total sum which is less than 33 .

In the second test case, the maximum subset a1,a2a_1, a_2 has a sum equal to 1212 , so Polycarp should choose a team with the maximum total sum which is less than 1212 .

In the third test case, the maximum subset a1,a3a_1, a_3 has a sum equal to 99 .

In the fourth test case, the maximum subset a1,a2a_1, a_2 has a sum equal to 88 .

In the fifth test case, there are several subsets with a maximum sum equal to 33 , so Polycarp should choose a team with a lower total sum.

输入输出样例

  • 输入#1

    5
    5
    1 -1 1 -1 1
    2
    11 1
    3
    5 -3 4
    3
    5 3 -4
    5
    -1 0 3 -3 0

    输出#1

    2
    11101
    11
    10
    6
    111
    5
    100
    2
    10100

说明/提示

In the first test case, the maximum subset a1,a3,a5a_1, a_3, a_5 has a sum equal to 33 , so Polycarp should choose a team with the maximum total sum which is less than 33 .

In the second test case, the maximum subset a1,a2a_1, a_2 has a sum equal to 1212 , so Polycarp should choose a team with the maximum total sum which is less than 1212 .

In the third test case, the maximum subset a1,a3a_1, a_3 has a sum equal to 99 .

In the fourth test case, the maximum subset a1,a2a_1, a_2 has a sum equal to 88 .

In the fifth test case, there are several subsets with a maximum sum equal to 33 , so Polycarp should choose a team with a lower total sum.

首页