CF1121B.Mike and Children
普及-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Mike decided to teach programming to children in an elementary school. He knows that it is not an easy task to interest children in that age to code. That is why he decided to give each child two sweets.
Mike has n sweets with sizes a1,a2,…,an. All his sweets have different sizes. That is, there is no such pair (i,j) (1≤i,j≤n) such that i=j and ai=aj.
Since Mike has taught for many years, he knows that if he gives two sweets with sizes ai and aj to one child and ak and ap to another, where (ai+aj)=(ak+ap), then a child who has a smaller sum of sizes will be upset. That is, if there are two children who have different sums of sweets, then one of them will be upset. Apparently, Mike does not want somebody to be upset.
Mike wants to invite children giving each of them two sweets. Obviously, he can't give one sweet to two or more children. His goal is to invite as many children as he can.
Since Mike is busy preparing to his first lecture in the elementary school, he is asking you to find the maximum number of children he can invite giving each of them two sweets in such way that nobody will be upset.
迈克决定在一所小学里教孩子们编程。他知道,要让这个年龄段的孩子对编程产生兴趣并非易事。因此,他决定给每个孩子两颗糖果。
迈克共有 n 颗糖果,大小分别为 a1,a2,…,an。所有糖果的大小互不相同,即不存在满足 i=j 且 ai=aj 的下标对 (i,j)(其中 1≤i,j≤n)。
由于迈克已有多年的教学经验,他深知:若将大小为 ai 和 aj 的两颗糖果分给一个孩子,而将大小为 ak 和 ap 的两颗糖果分给另一个孩子,且 (ai+aj)=(ak+ap),那么获得糖果总大小较小的孩子会感到沮丧。换言之,只要存在两个孩子所获糖果的大小之和不同,其中一人便会沮丧。显然,迈克不希望有任何孩子感到沮丧。
迈克希望邀请尽可能多的孩子,每位孩子恰好分得两颗糖果。显然,一颗糖果不能分给两个或更多孩子。他的目标是最大化可邀请的孩子人数。
由于迈克正忙于准备他在小学的第一堂课,他请你帮忙找出在确保无人沮丧的前提下,他最多能邀请多少个孩子(即每位孩子分得两颗糖果,且所有孩子所得糖果大小之和均相等)。
输入格式
The first line contains one integer n (2≤n≤1000) — the number of sweets Mike has.
The second line contains n integers a1,a2,…,an (1≤ai≤105) — the sizes of the sweets. It is guaranteed that all integers are distinct.
第一行包含一个整数 n(2≤n≤1000)—— Mike 拥有的糖果数量。
第二行包含 n 个整数 a1,a2,…,an(1≤ai≤105)—— 糖果的大小。保证所有整数互不相同。
输出格式
Print one integer — the maximum number of children Mike can invite giving each of them two sweets in such way that nobody will be upset.
输出一个整数——Mike 最多能邀请多少个孩子,使得每个孩子都能分到两颗糖果,且没有人会不高兴。
输入输出样例
输入#1
8 1 8 3 11 4 9 2 7
输出#1
3
输入#2
7 3 1 7 11 9 2 12
输出#2
2
说明/提示
In the first example, Mike can give 9+2=11 to one child, 8+3=11 to another one, and 7+4=11 to the third child. Therefore, Mike can invite three children. Note that it is not the only solution.
In the second example, Mike can give 3+9=12 to one child and 1+11 to another one. Therefore, Mike can invite two children. Note that it is not the only solution.
在第一个例子中,Mike 可以给一个孩子 9+2=11,给另一个孩子 8+3=11,再给第三个孩子 7+4=11。因此,Mike 最多可以邀请三名孩子。注意,这并非唯一解。
在第二个例子中,Mike 可以给一个孩子 3+9=12,给另一个孩子 1+11。因此,Mike 最多可以邀请两名孩子。注意,这并非唯一解。
输入解题思路,AI测评打分。不知道怎么写?