国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

【codeforce】403 Div.2 A Andryusha and Socks

2019-11-06 06:34:11
字體:
來源:轉載
供稿:網友
A. Andryusha and Sockstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

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 from1 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?

Input

The first line contains the single integer n (1?≤?n?≤?105) — the number of sock pairs.

The second line contains 2n integers x1,?x2,?...,?x2n (1?≤?xi?≤?n), which describe the order in which Andryusha took the socks from the bag. More precisely,xi means that thei-th sock Andryusha took out was from pairxi.

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

Output

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

ExamplesInput
11 1Output
1Input
32 1 1 3 2 3Output
2

Note

In the first example Andryusha took a sock from the first pair and put it on the table. Then he took the next sock which is from the first pair as well, so he immediately puts both socks to the wardrobe. Thus, at most one sock was on the table at the same time.

In the second example Andryusha behaved as follows:

Initially the table was empty, he took out a sock from pair 2 and put it on the table. Sock (2) was on the table. Andryusha took out a sock from pair1 and put it on the table. Socks (1,?2) were on the table. Andryusha took out a sock from pair1, and put this pair into the wardrobe. Sock (2) was on the table. Andryusha took out a sock from pair3 and put it on the table. Socks (2,?3) were on the table. Andryusha took out a sock from pair2, and put this pair into the wardrobe. Sock (3) was on the table. Andryusha took out a sock from pair3 and put this pair into the wardrobe.

Thus, at most two socks were on the table at the same time.

code:

#include<cstdio>#include<cstring>#include<algorithm>using namespace std;int main(){	int x,n;int s[200001];	while(~scanf("%d",&n)){		int num=0,sum=0;		memset(s,0,sizeof(s));		for(int i=1;i<=2*n;i++){			scanf("%d",&x);			s[x]++;			if(s[x]==2)			num--;			else			num++;			sum=max(sum,num);		}		printf("%d/n",sum);	}	return 0; } 


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 吴忠市| 固阳县| 泾川县| 台北县| 贵德县| 交城县| 玛多县| 甘孜县| 龙南县| 福贡县| 济阳县| 定州市| 凌源市| 廊坊市| 仪征市| 孝感市| 婺源县| 大洼县| 保定市| 武川县| 荥经县| 枞阳县| 岢岚县| 余庆县| 扬中市| 福建省| 威海市| 黄平县| 陇川县| 恩平市| 改则县| 盱眙县| 邵武市| 依安县| 塔河县| 嘉荫县| 赫章县| 佛坪县| 安徽省| 福贡县| 富宁县|