A. Andryusha and Socks
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

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

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 the i-th sock Andryusha took out was from pair xi.

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.

Examples
input
1
1 1
output
1
input
3
2 1 1 3 2 3
output
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 pair 1 and put it on the table.
  • Socks (1, 2) were on the table. Andryusha took out a sock from pair 1, and put this pair into the wardrobe.
  • Sock (2) was on the table. Andryusha took out a sock from pair 3 and put it on the table.
  • Socks (2, 3) were on the table. Andryusha took out a sock from pair 2, and put this pair into the wardrobe.
  • Sock (3) was on the table. Andryusha took out a sock from pair 3 and put this pair into the wardrobe.

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

 
思路:
  模拟;
 
 
来,上代码:

#include <cstdio>
#include <iostream> #define maxn 100005 using namespace std; int n,pos,ans,pos_; char Cget; bool if_[maxn]; inline void in(int &now)
{
now=,Cget=getchar();
while(Cget>''||Cget<'') Cget=getchar();
while(Cget>=''&&Cget<='')
{
now=now*+Cget-'';
Cget=getchar();
}
} int main()
{
in(n);
for(int i=;i<=(n<<);i++)
{
in(pos_);
if(!if_[pos_])
{
if_[pos_]=true;
pos++;
ans=max(ans,pos);
}
else pos--;
}
cout<<ans;
return ;
}

AC日记——Andryusha and Socks Codeforces 780a的更多相关文章

  1. AC日记——Andryusha and Colored Balloons codeforces 780c

    C - Andryusha and Colored Balloons 思路: 水题: 代码: #include <cstdio> #include <cstring> #inc ...

  2. AC日记——Dynamic Problem Scoring codeforces 807d

    Dynamic Problem Scoring 思路: 水题: 代码: #include <cstdio> #include <cstring> #include <io ...

  3. AC日记——Sign on Fence Codeforces 484e

    E. Sign on Fence time limit per test 4 seconds memory limit per test 256 megabytes input standard in ...

  4. AC日记——Sagheer, the Hausmeister codeforces 812b

    812B - Sagheer, the Hausmeister 思路: 搜索: 代码: #include <cstdio> #include <cstring> #includ ...

  5. AC日记——Sagheer and Crossroads codeforces 812a

    812A - Sagheer and Crossroads 思路: 模拟: 代码: #include <cstdio> #include <cstring> #include ...

  6. AC日记——Is it rated? codeforces 807a

    Is it rated? 思路: 水题: 代码: #include <cstdio> #include <cstring> using namespace std; ],b[] ...

  7. Ac日记——Distances to Zero codeforces 803b

    803B - Distances to Zero 思路: 水题: 代码: #include <cstdio> #include <cstring> #include <i ...

  8. AC日记——Mice and Holes codeforces 797f

    797F - Mice and Holes 思路: XXYXX: 代码: #include <cmath> #include <cstdio> #include <cst ...

  9. AC日记——Roma and Poker codeforces 803e

    803E - Roma and Poker 思路: 赢或输或者平的序列: 赢和平的差的绝对值不得超过k: 结束时差的绝对值必须为k: 当“?”时可以自己决定为什么状态: 输出最终序列或者NO: dp( ...

随机推荐

  1. Java-JFrame开发汇总整理

    Java-JFrame开发汇总整理 在CS框架下,可以通过java代码开发JFrame弹窗体的功能,即类似于QQ登录等安装在计算机中的程序,通过java开发CS中C即客户端的一般用到的知识点如下: 一 ...

  2. JavaScript取出字符串中括号里的内容

    /** * 取出中括号内的内容 * @param text * @returns {string} */ export function getBracketStr(text) { let resul ...

  3. spring事务(Transaction )报 marked as rollback-only异常的原因及解决方法

    很多朋友在使用spring+hibernate或mybatis等框架时经常遇到报Transaction rolled back because it has been marked as rollba ...

  4. nrf52裸机学习——GPIO操作

    /** * @brief Function for writing a value to a GPIO pin. * * Note that the pin must be configured as ...

  5. servlet 作用

    什么是Servlet Servlet是一个Java编写的程序,此程序是基于Http协议的,在服务器端运行的(如tomcat),是按照Servlet规范编写的一个Java类. 在BS架构中,早期的Web ...

  6. spring boot配置

    spring.application.name=XXXXXserver.port=9515 # health显示down的问题endpoints.health.sensitive= falsemana ...

  7. python中json操作了解

    什么是接口? 交换数据 http://openweathermap.org/current json简介 JSON 是存储和交换文本信息的语法.类似 XML JSON 语法是 JavaScript 语 ...

  8. day03_04 文件后缀及系统环境变量

    进入cmd,如果想直接切换盘符的话,操作如下 dir命令---查看目录下的文件及文件夹 cd命令---想进入某个目录,就是是双击文件夹进入目录的命令,按table键有神奇效果哦 cd ..命令---类 ...

  9. 02-python进阶-文件操作

    新建一个文件 内容是从 0-9的整数 #coding:utf-8 f = open('1.txt','w') #r 只读 w 可写 a追加 for i in range(0,10): f.write( ...

  10. 编绎调试HotSpot JVM及在Eclipse里调试HotSpot一些步骤

    编绎整个OpenJDK要很久,而且有很多东西是不需要的.研究HotSpot的话,其实只要下HotSpot部分的代码就可以了. 下面简单记录下编绎调试HotSpot一些步骤. 一.编绎 进入hotsop ...