CF1399C.Boats Competition

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

There are nn people who want to participate in a boat competition. The weight of the ii -th participant is wiw_i . Only teams consisting of two people can participate in this competition. As an organizer, you think that it's fair to allow only teams with the same total weight.

So, if there are kk teams (a1,b1)(a_1, b_1) , (a2,b2)(a_2, b_2) , \dots , (ak,bk)(a_k, b_k) , where aia_i is the weight of the first participant of the ii -th team and bib_i is the weight of the second participant of the ii -th team, then the condition a1+b1=a2+b2==ak+bk=sa_1 + b_1 = a_2 + b_2 = \dots = a_k + b_k = s , where ss is the total weight of each team, should be satisfied.

Your task is to choose such ss that the number of teams people can create is the maximum possible. Note that each participant can be in no more than one team.

You have to answer tt independent test cases.

输入格式

The first line of the input contains one integer tt ( 1t10001 \le t \le 1000 ) — the number of test cases. Then tt test cases follow.

The first line of the test case contains one integer nn ( 1n501 \le n \le 50 ) — the number of participants. The second line of the test case contains nn integers w1,w2,,wnw_1, w_2, \dots, w_n ( 1win1 \le w_i \le n ), where wiw_i is the weight of the ii -th participant.

输出格式

For each test case, print one integer kk : the maximum number of teams people can compose with the total weight ss , if you choose ss optimally.

输入输出样例

  • 输入#1

    5
    5
    1 2 3 4 5
    8
    6 6 6 6 6 6 8 8
    8
    1 2 2 1 2 1 1 2
    3
    1 3 3
    6
    1 1 3 4 2 2

    输出#1

    2
    3
    4
    1
    2

说明/提示

In the first test case of the example, we can reach the optimal answer for s=6s=6 . Then the first boat is used by participants 11 and 55 and the second boat is used by participants 22 and 44 (indices are the same as weights).

In the second test case of the example, we can reach the optimal answer for s=12s=12 . Then first 66 participants can form 33 pairs.

In the third test case of the example, we can reach the optimal answer for s=3s=3 . The answer is 44 because we have 44 participants with weight 11 and 44 participants with weight 22 .

In the fourth test case of the example, we can reach the optimal answer for s=4s=4 or s=6s=6 .

In the fifth test case of the example, we can reach the optimal answer for s=3s=3 . Note that participant with weight 33 can't use the boat because there is no suitable pair for him in the list.

首页