AmazonOA #45
Min Operations to Ship Products
估计中等可在线判题
One shipment can send two items from different locations, or a single item on its own. Find the minimum number of shipments needed to send all items.
输入格式
The first line contains n (1..100000), and the second line contains n locations (1..10⁹).
输出格式
Output a single integer answer.
样例 1
输入:
5
1 8 6 7 7
输出:
3
样例 2
输入:
3
1 1 1
输出:
3
样例 3
输入:
2
1 2
输出:
1
样例说明
Example 1: the two 7s are paired with 1 and 8 respectively, and 6 is shipped alone, for 3 in total. Example 2: items from the same location cannot ship together, so 3 shipments are needed. Example 3: the two locations ship together, 1 shipment.