B. Berland National Library
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Berland National Library has recently been built in the capital of Berland. In addition, in the library you can take any of the collected works of Berland leaders, the library has a reading room.

Today was the pilot launch of an automated reading room visitors' accounting system! The scanner of the system is installed at the entrance to the reading room. It records the events of the form "reader entered room", "reader left room". Every reader is assigned
aregistration number during the registration procedure at the library — it's a unique integer from 1 to 106.
Thus, the system logs events of two forms:

  • "+ ri"
    — the reader with registration number ri entered
    the room;
  • "- ri"
    — the reader with registration number ri left
    the room.

The first launch of the system was a success, it functioned for some period of time, and, at the time of its launch and at the time of its shutdown, the reading room may already have visitors.

Significant funds of the budget of Berland have been spent on the design and installation of the system. Therefore, some of the citizens of the capital now demand to explain the need for this system and the benefits that its implementation will bring. Now,
the developers of the system need to urgently come up with reasons for its existence.

Help the system developers to find the minimum possible capacity of the reading room (in visitors) using the log of the system available to you.

Input

The first line contains a positive integer n (1 ≤ n ≤ 100)
— the number of records in the system log. Next follow n events from the system journal in the order in which the were made. Each event
was written on a single line and looks as "+ ri"
or "- ri",
where ri is
an integer from 1 to 106,
the registration number of the visitor (that is, distinct visitors always have distinct registration numbers).

It is guaranteed that the log is not contradictory, that is, for every visitor the types of any of his two consecutive events are distinct. Before starting the system, and after stopping the room may possibly contain visitors.

Output

Print a single integer — the minimum possible capacity of the reading room.

Sample test(s)
input
6
+ 12001
- 12001
- 1
- 1200
+ 1
+ 7
output
3
input
2
- 1
- 2
output
2
input
2
+ 1
- 1
output
1
Note

In the first sample test, the system log will ensure that at some point in the reading room were visitors with registration numbers 1, 1200and 12001.
More people were not in the room at the same time based on the log. Therefore, the answer to the test is 3.

#include<stdio.h>
#include<string.h> const int N = 1000005;
bool vist[N];
int main()
{
int n,ans;
char ch[5];
while(scanf("%d",&n)>0)
{
memset(vist,0,sizeof(vist));
int maxcap=0,num=0;
while(n--)
{
scanf("%s%d",ch,&ans);
if(ch[0]=='-'){
if(vist[ans])
vist[ans]=0,num--;
else
maxcap++;
}
else{
if(num==maxcap)
maxcap++;
if(vist[ans]==0)
num++;
vist[ans]=1; }
}
printf("%d\n",maxcap);
}
}

Codeforces B - Berland National Library的更多相关文章

  1. CodeForces 567B Berland National Library

    Description Berland National Library has recently been built in the capital of Berland. In addition, ...

  2. CodeForces 567B Berland National Library hdu-5477 A Sweet Journey

    这类题一个操作增加多少,一个操作减少多少,求最少刚开始为多少,在中途不会出现负值,模拟一遍,用一个数记下最大的即可 #include<cstdio> #include<cstring ...

  3. Codeforces Round #Pi (Div. 2) B. Berland National Library set

    B. Berland National LibraryTime Limit: 2 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest ...

  4. Codeforces Round #Pi (Div. 2) B. Berland National Library 模拟

    B. Berland National LibraryTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contes ...

  5. 构造 Codeforces Round #Pi (Div. 2) B. Berland National Library

    题目传送门 /* 题意:给出一系列读者出行的记录,+表示一个读者进入,-表示一个读者离开,可能之前已经有读者在图书馆 构造:now记录当前图书馆人数,sz记录最小的容量,in数组标记进去的读者,分情况 ...

  6. Codeforces Round #Pi (Div. 2) B Berland National Library

    B. Berland National Library time limit per test1 second memory limit per test256 megabytes inputstan ...

  7. Codeforces 567B:Berland National Library(模拟)

    time limit per test : 1 second memory limit per test : 256 megabytes input : standard input output : ...

  8. Berland National Library

    题目链接:http://codeforces.com/problemset/problem/567/B 题目描述: Berland National Library has recently been ...

  9. [Codeforces 1005F]Berland and the Shortest Paths(最短路树+dfs)

    [Codeforces 1005F]Berland and the Shortest Paths(最短路树+dfs) 题面 题意:给你一个无向图,1为起点,求生成树让起点到其他个点的距离最小,距离最小 ...

随机推荐

  1. Automatic WordPress Updates Using FTP/FTPS or SSH

    Introduction When working with WordPress in a more secure environment where websites are not entirel ...

  2. MC34063A development aid

    http://www.nomad.ee/micros/mc34063a/index.shtml This is a simple-minded design tool that allows you ...

  3. ICD2 VPP limiter for new PIC microcontrollers.

    http://www.circuitsathome.com/mcu/pic_vpp_limiter VOUT = 2.5V * ( 1 + 24/10 ) = 2.5 * 3.4 = 8.5V New ...

  4. Windows程序的打包,部署(vs项目打包vs2013)---ShinePans

    Windows 应用程序在开发完毕之后,怎样将程序打包并制作成安装程序在客户机上部署 是每一个windows应用程序开发完毕之后都必须面对的问题. 学习目标:                    部 ...

  5. datagrid单元格格式化样式化

    本文体验datagrid单元格的格式化和样式化.   datagrid显示的DOM结构 <td field="code"> <div style="te ...

  6. unity3d如何快速接入渠道SDK之Unity篇

    原文链接: http://bbs.tianya.cn/post-414-53320-1.shtml 首先我们讲一下,为什么要介绍这个插件? 是因为这个插件极大的简化了我对接渠道SDK的工作量,精力和时 ...

  7. java执行ping命令

    public static void get() throws IOException{ String address="10.132.118.110"; Process proc ...

  8. Visual GC(监控垃圾回收器)

    Java VisualVM默认没有安装Visual GC插件,需要手动安装,JDK的安装目录的bin目露下双击jvisualvm.exe,即可打开Java VisualVM,点击菜单栏 工具-> ...

  9. [6] 胶囊体(Capsule)图形的生成算法

    顶点数据的生成 bool YfBuildCapsuleVertices ( Yreal radius, Yreal height, Yuint slices, Yuint stacks, YeOrig ...

  10. 解决报错"Your security system have blocked an application with expired or not yet valid certificate from running"

    方法如下: Go to Control Panel Java in the Security tab click the "Edit Site List-" button clic ...