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. $addToSet $push

    结果:

  2. 将数据库的数据导入solr索引库中

    在solr与tomcat整合文章中,我用的索引库是mycore,现在就以这个为例. 首先要准备jar包:solr-dataimporthandler-4.8.1.jar.solr-dataimport ...

  3. TreeSize Free 查看文件夹大小 v2.3.3 汉化版

    <b>软件名称: <a href="http://www.bkill.com/download/30740.html"><font color=&qu ...

  4. 9---PIP 管理工具的使用

    Python 不仅有强大的内置模块,还提供强大的三方模块. 官方网站: https://pypi.python.org/pypi 要适用三方的模块需要使用pip管理工具. 1.在安装pip前,请确认w ...

  5. [笔记]Practical Lessons from Predicting Clicks on Ads at Facebook

    ABSTRACT 这篇paper中作者结合GBDT和LR,取得了很好的效果,比单个模型的效果高出3%.随后作者研究了对整体预测系统产生影响的几个因素,发现Feature+Model的贡献程度最大,而其 ...

  6. robotframework的分支和循环

    分支: run keyword if  | condition |  do something ...   |      else if | condition | do something ... ...

  7. msdn我告诉你

    http://msdn.itellyou.cn/ 微软旗下所有的msdn订阅软件资源 均为ed2k资源 Business Solutions MSDN Library 工具和资源 应用程序 开发人员工 ...

  8. Windows API 之 VirtualAlloc

    Reserves, commits, or changes the state of a region of pages in the virtual address space of the cal ...

  9. Sharepoint 弹出消息提示框 .

    在event receiver中如何弹出一个类似winform中messagebox.show 的框? 那我要对用户显示一些错误信息或者提示信息怎么搞? 1. 如果是在ItemAdding或者其他进行 ...

  10. [code]高精度运算

    数组存储整数,模拟手算进行四则运算 阶乘精确值 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 #includ ...