AmazonOA #16
Find Maximum Packages
估计中等可在线判题
Choose a single target total price T. Each bundle contains one or two products whose total price is T; each product can be used at most once, and some products may be left unused. Find the maximum number of bundles that can be formed.
输入格式
The first line contains n (1..200000), and the second line contains n prices (1..2000).
输出格式
Output one integer, the answer required by the problem.
样例 1
输入:
9
4 5 10 3 1 2 2 2 3
输出:
4
样例 2
输入:
3
2 2 2
输出:
3
样例 3
输入:
1
1
输出:
1
样例说明
Example 1: with target price 5 you can form [5], [4,1] and two [3,2], 4 bundles in total; enumerating other targets cannot give more. Example 2: with target price 2, each 2 forms its own bundle, 3 bundles in total, instead of forcing them into pairs. Example 3: the only product 1 forms a bundle by itself, so the answer is 1.