题库练习 Andryusha and Socks
← 上一题 下一题 →

A10776 | Andryusha and Socks

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

Andryusha is an orderly boy and likes to keep things in their place.

Today he faced a problem to put his socks in the wardrobe. He has $n$ distinct pairs of socks which are initially in a bag. The pairs are numbered from $1$ to $n$ . Andryusha wants to put paired socks together and put them in the wardrobe. He takes the socks one by one from the bag, and for each sock he looks whether the pair of this sock has been already took out of the bag, or not. If not (that means the pair of this sock is still in the bag), he puts the current socks on the table in front of him. Otherwise, he puts both socks from the pair to the wardrobe.

Andryusha remembers the order in which he took the socks from the bag. Can you tell him what is the maximum number of socks that were on the table at the same time?

输入格式

The first line contains the single integer $n$ ( $1<=n<=10^{5}$ ) — the number of sock pairs.

The second line contains $2n$ integers $x_{1},x_{2},...,x_{2n}$ ( $1<=x_{i}<=n$ ), which describe the order in which Andryusha took the socks from the bag. More precisely, $x_{i}$ means that the $i$ -th sock Andryusha took out was from pair $x_{i}$ .

It is guaranteed that Andryusha took exactly two socks of each pair.

输出格式

Print single integer — the maximum number of socks that were on the table at the same time.

输入输出样例

输入 #1
1
1 1
输出 #1
1
输入 #2
3
2 1 1 3 2 3
输出 #2
2
C++ 编辑器
输入
输出