No.2851 Make Pairs
問題文最終更新日: 2024-08-21 21:37:32
English (AI translation)
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence.
Back to the original
yukicoder contest 442 MMA Contest 019
(順位表)
の他の問題:
Problem Statement
$N$ cards are arranged in a row, and the $i$-th card from the left has the number $A_i$ written on it.
You may perform the following operation any number of times.
- Choose $2$ cards with the same number written on them and erase those cards.
Find the maximum number of operations you can perform.
Constraints
- $1 \leq N \leq 2 \times 10^5$
- $1 \leq A_i \leq N$
- All inputs are integers.
Input
The input is given from standard input in the following format.
$N$
$A_1$ $A_2$ ... $A_{N}$
Output
Print the answer to the problem on one line.
Sample
Sample 1
Input
5 1 2 3 1 2
Output
2
You can perform the operations as follows.
- Choose the $1$-st and $4$-th cards from the left and erase them.
- Choose the $2$-nd and $5$-th cards from the left and erase them.
It is impossible to perform more than $2$ operations, so print $2$.
Sample 2
Input
10 1 2 3 4 5 6 7 8 9 8
Output
1
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。