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.

  1. Sample Input
  2. Input
  3.  
  4. +
  5. -
  6. -
  7. -
  8. +
  9. +
  10. Output
  11.  
  12. Input
  13.  
  14. -
  15. -
  16. Output
  17.  
  18. Input
  19.  
  20. +
  21. -
  22. Output
  23.  
  24. Hint
  25. 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代码:

  1. #include<stdio.h>
  2. #include<string.h>
  3. #include<math.h>
  4. #include<queue>
  5. #include<algorithm>
  6. #include<time.h>
  7. using namespace std;
  8. #define N 1000050
  9.  
  10. int a[N];
  11. char s[N];
  12.  
  13. int main()
  14. {
  15. int n,i,x;
  16.  
  17. while(scanf("%d", &n) != EOF)
  18. {
  19. memset(a,,sizeof(a));
  20.  
  21. int ans=;///记录人数变化
  22. int maxx=;///储存最大人数
  23. for(i=;i<n;i++)
  24. {
  25. scanf("%s %d", s,&x);
  26.  
  27. if(s[]=='+')
  28. {
  29. a[x]=;///标记在图书馆里
  30. ans++;
  31. maxx=max(ans,maxx);
  32. }
  33. else
  34. {
  35. if(a[x])
  36. ans--;
  37. else
  38. maxx++;
  39. }
  40. }
  41. printf("%d\n", maxx);
  42. }
  43. return ;
  44. }

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. MC- 挂单STOP交易

    using System; using System.Drawing; using System.Linq; using PowerLanguage.Function; using ATCenterP ...

  2. Linux CPU 核数检查脚本

    #!/bin/bash physicalNumber=0 coreNumber=0 logicalNumber=0 HTNumber=0 logicalNumber=$(grep "proc ...

  3. As3.0 TextField

    一 TextField 对象的方法 方法 说明 TextField.addListener 加入接收触发事件如文本域内容变化或滚动变化的监听对象,触发事件可以参看最后一个表. TextField.ge ...

  4. 五种JSP页面跳转方法详解

    1. RequestDispatcher.forward() 是在服务器端起作用,当使用forward()时,Servlet engine传递HTTP请求从当前的Servlet or JSP到另外一个 ...

  5. drawableLayout的使用(转载讲的比较清晰的文章)

    创建drawbler的布局文件 初始化drawbler的列表 响应drawable列表点击事件 现在侧滑菜单使用很多,大都是通过SlidingMenu实现.现在也可以通过DrawerLayout 创建 ...

  6. angularjs上传图片插件使用

    一. angurlajs 相关 远程 jar 包 https://code.angularjs.org/angular-1.0.1.min.js 二. 正文 1. html 部分 <!-- 需要 ...

  7. point类型·

    指针的类型 不同类型的指针,从内存需求的观点来说,没有什么不同!他们三个都需要足够的内存来繁殖一个机器地址,"指向不同类型之各指针"之间的差异,既不在其指针表示法不同,也不再其内容 ...

  8. MFC中获取系统当前时间

    1.使用CTime类 CString str; //获取系统时间 CTime tm; tm=CTime::GetCurrentTime(); str=tm.Format("现在时间是%Y年% ...

  9. Ubuntu上安装mono

    How do I use badgerports? badgerports is an Ubuntu repository. In order to use it, you must add it t ...

  10. PMBok项目管理

    这就是项目管理的九大领域:整合管理.范围管理.时间管理.费用管理.质量管理.人力资源管理.沟通管理.风险管理.采购管理. 项目管理好像一头大象,将其大卸九块之后,要装进冰箱就容易多了. 看看书上是怎样 ...