#abc295c. C - Socks

C - Socks

Score : 300300 points

问题描述

你有 NN 只袜子。第 ii 只袜子的颜色是 AiA_i

你想尽可能多地执行以下操作。最多能执行多少次?

  • 选择两只颜色相同且尚未配对的袜子,将它们配对。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

You have NN socks. The color of the ii-th sock is AiA_i.

You want to perform the following operation as many times as possible. How many times can it be performed at most?

  • Choose two same-colored socks that are not paired yet, and pair them.

Constraints

  • 1N5×1051\leq N \leq 5\times 10^5
  • 1Ai1091\leq A_i \leq 10^9
  • All values in the input are integers.

Input

The input is given from Standard Input in the following format:

NN

A1A_1 A2A_2 \dots ANA_N

Output

Print an integer representing the answer.

Sample Input 1

6
4 1 7 4 1 4

Sample Output 1

2

You can do the operation twice as follows.

  • Choose two socks with the color 11 and pair them.
  • Choose two socks with the color 44 and pair them.

Then, you will be left with one sock with the color 44 and another with the color 77, so you can no longer do the operation. There is no way to do the operation three or more times, so you should print 22.

Sample Input 2

1
158260522

Sample Output 2

0

Sample Input 3

10
295 2 29 295 29 2 29 295 2 29

Sample Output 3

4

update @ 2024/3/10 12:15:54