Description

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 Input
Input +
-
-
-
+
+
Output Input -
-
Output Input +
-
Output Hint
In the first sample test, the system log will ensure that at some point in the reading room were visitors with registration numbers , and . More people were not in the room at the same time based on the log. Therefore, the answer to the test is .

题目链接:http://codeforces.com/problemset/problem/567/B

********************************************

题意:给出一个图书馆人员进出情况,问图书馆满足题意的最小容量是多少。

分析:模拟题,开个数组标记状态。结果是有记录的最大值+没有记录只有'-'的人的数量。

AC代码:

 #include<stdio.h>
#include<string.h>
#include<math.h>
#include<queue>
#include<algorithm>
#include<time.h>
using namespace std;
#define N 1000050 int a[N];
char s[N]; int main()
{
int n,i,x; while(scanf("%d", &n) != EOF)
{
memset(a,,sizeof(a)); int ans=;///记录人数变化
int maxx=;///储存最大人数
for(i=;i<n;i++)
{
scanf("%s %d", s,&x); if(s[]=='+')
{
a[x]=;///标记在图书馆里
ans++;
maxx=max(ans,maxx);
}
else
{
if(a[x])
ans--;
else
maxx++;
}
}
printf("%d\n", maxx);
}
return ;
}

CodeForces 567B Berland National Library的更多相关文章

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

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

  2. Codeforces B - Berland National Library

    B. Berland National Library time limit per test 1 second memory limit per test 256 megabytes input s ...

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

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

  4. 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 ...

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

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

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

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

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

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

  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. 图片拉伸:resizableImageWithCapInsets

    iOS 5.0 在iOS 5.0中,UIImage有一个新方法可以处理图片的拉伸问题 - (UIImage *)resizableImageWithCapInsets:(UIEdgeInsets)ca ...

  2. 生成SQL脚本的方法

    2点需要注意的关键: (1)选择特定数据库对象不包含用户选项: (2)要编写脚本的数据的类型选择"架构和数据".

  3. form表单验证提示语句

    <input id="idcardcode" name="idcardcode" class="form-control"       ...

  4. java 图形界面 mvc模式控制

    使用模型-视图-控件结构来开发GUI程序. 下面的程序演示了MVC模式开发的java程序. 其中CircleModel为模型,包含了圆的半径,是否填充,等属性. CircleView为视图,显示这个圆 ...

  5. C# 鼠标事件弹框

    if (e.Button == MouseButtons.Right) { if (gridView1.GetFocusedRowCellValue("color").ToStri ...

  6. Strusts2--课程笔记4

    类型转换器: Struts2默认情况下可以将表单中输入的文本数据转换为相应的基本数据类型.这个功能的实现,主要是由于Struts2内置了类型转换器.这些转换器在struts-default.xml中可 ...

  7. 学习笔记——解释器模式Interpreter

    解释器模式,其实就是编译原理中的语法解释器,如果用在项目中,可以用于实现动态脚本的解析,也就是说项目可以支持用户脚本扩展. 但实际上,这种运行时解释,效率很慢,如果不是很需要的话,不建议使用. 一种简 ...

  8. 标准IO库

    IO标准库类型和头文件

  9. VBS一键配置VOIP脚本(其中包括VBS操作JS网页中的按钮事件--直接执行确认按钮中的脚本代码)

    Dim ws,fso,IESet IE = WScript.createobject("InternetExplorer.Application")Set ws = WScript ...

  10. VBS 文件选择框,选择Excel文件

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 on error resume Next Set objDialog=CreateObject("UserAcc ...