#K76822. Maximum Sock Pairs
Maximum Sock Pairs
Maximum Sock Pairs
You are given a list of socks, each identified by its color represented as an integer. Your task is to determine the maximum number of matching pairs of socks that can be formed from the list. A pair consists of two socks of the same color.
Input: The first line contains an integer n that denotes the total number of socks. The second line contains n integers where each integer represents the color of a sock.
Output: Output a single integer representing the maximum number of pairs that can be formed.
Formally, if the count of socks of a certain color is c, then the number of pairs for that color is \(\lfloor c/2 \rfloor\). The answer is the sum of pairs over all colors.
inputFormat
The first line of input contains an integer n, the number of socks. The second line contains n space-separated integers representing the color of each sock.
outputFormat
Output a single integer which is the maximum number of matching pairs of socks that can be formed.## sample
9
10 20 20 10 10 30 50 10 20
3
</p>