B. Berland National Library
Time Limit: 20 Sec

Memory Limit: 256 MB

题目连接

http://codeforces.com/contest/567/problem/B

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

6
+ 12001
- 12001
- 1
- 1200
+ 1
+ 7

Sample Output

3

HINT

题意

+表示进去了一个编号为x的人,-表示出去了一个编号为x的人,然后每个人会使用一个房间

问你这个地方最少得有多少个房间

题解

模拟一下就好了,如果这个人出去的话,就会空出一个房间,那么下一个人进去就会占据这个房间

代码

#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define test freopen("test.txt","r",stdin)
#define maxn 2000001
#define mod 1000000007
#define eps 1e-9
const int inf=0x3f3f3f3f;
const ll infll = 0x3f3f3f3f3f3f3f3fLL;
inline ll read()
{
ll x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
//************************************************************************************** map<int,int> H;
int main()
{
int n=read();
int now=;
int tip=;
int ans=;
for(int i=;i<n;i++)
{
string s;
cin>>s;
int k=read();
if(s[]=='+')
{
if(tip>)
{
tip--;
H[k]=;
}
else
{
now++;
H[k]=;
}
}
else
{
if(H[k]==)
H[k]=,tip++;
else
now++,tip++;
}
ans=max(ans,now);
}
cout<<ans<<endl;
}

Codeforces Round #Pi (Div. 2) B. Berland National Library 模拟的更多相关文章

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

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

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

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

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

  4. map Codeforces Round #Pi (Div. 2) C. Geometric Progression

    题目传送门 /* 题意:问选出3个数成等比数列有多少种选法 map:c1记录是第二个数或第三个数的选法,c2表示所有数字出现的次数.别人的代码很短,思维巧妙 */ /***************** ...

  5. Codeforces Round #Pi (Div. 2)(A,B,C,D)

    A题: 题目地址:Lineland Mail #include <stdio.h> #include <math.h> #include <string.h> #i ...

  6. Codeforces Round #Pi (Div. 2) ABCDEF已更新

    A. Lineland Mail time limit per test 3 seconds memory limit per test 256 megabytes input standard in ...

  7. Codeforces Round #367 (Div. 2) B. Interesting drink (模拟)

    Interesting drink 题目链接: http://codeforces.com/contest/706/problem/B Description Vasiliy likes to res ...

  8. codeforces Round #Pi (div.2) 567ABCD

    567A Lineland Mail题意:一些城市在一个x轴上,他们之间非常喜欢写信交流.送信的费用就是两个城市之间的距离,问每个城市写一封信给其它城市所花费的最小费用和最大的费用. 没什么好说的.直 ...

  9. Codeforces Round #Pi (Div. 2) E. President and Roads tarjan+最短路

    E. President and RoadsTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/567 ...

随机推荐

  1. SpringMVC——实现拦截器

    1. SpringMVC拦截器的概念与Struts2相同 2. 实现拦截器 (1) 项目结构 (2) 实现HandlerInterceptor接口 package com.zhengbin.contr ...

  2. Android中FragmentPagerAdapter对Fragment的缓存(一)

    ViewPager + FragmentPagerAdapter,时我们经常使用的一对搭档,其实际应用的代码也非常简单,但是也有一些容易被忽略的地方,这次我们就来讨论下FragmentPagerAda ...

  3. 关于ThinkPHP中Session不能夸模块/控制器使用的问题-网上的答案我做个补充

    1,确保c:/windows目录下有php.ini文件2,修改php.ini中的session.auto_start = 0 为 session.auto_start = 1  //设置自动开启ses ...

  4. Linux 系统编程

    简介和主要概念 Linux 系统编程最突出的特点是要求系统程序员对它们工作的的系统的硬件和操作系统有深入和全面的了解,当然它们还有库和系统调用上的区别. 系统编程分为:驱动编程.用户空间编程和网络编程 ...

  5. CodeForces 148D-Bag of mice(概率dp)

    题意: 袋子里有w个白球b个黑球,现在两个人轮流每次取一个球(不放回),先取到白球的获胜,当后手取走一个球时,袋子里的球会随机的漏掉一个,问先手获胜的概率. 分析: dp[i][j]表示袋子中i个白球 ...

  6. Python--类使用

    类使用的几个注意点: 1. 类的语法结构:2. __init__(self),3. __metaclass__=type, (新式类)4. super(subclassname, self).__in ...

  7. 白盒测试之gmock入门篇

    一.gmock是什么 gmock是google公司推出的一款开源的白盒测试工具.gmock是个很强大的东西,测试一个模块的时候,可能涉及到和其他模块交互,可以将模块之间的接口mock起来,模拟交互过程 ...

  8. uC/OS-II 移植笔记

    用过51.AVR.Freescale.STM32,但是写程序一直没有用过实时操作系统,一是因为写的项目不大,二是不太想去看手册学东西.现在写的项目也算比较大,因为需要,所以就学一下,这样也不至于每次的 ...

  9. CSAPP(2):程序的汇编表示(Linux版)

    程序员学习汇编代码的需求随着时间的推移发生了变化,开始时只要求程序员能直接用汇编语言编写程序,现在则要求他们能够阅读和理解编译器产生的代码. 下面是针对32位机器 数据格式 Intel用术语“字”(w ...

  10. 重读gets()与is函数的用法

    这是从百度百科上查找的资料: gets(): 从stdin流中读取字符串,直至接受到换行符或EOF时停止,并将读取的结果存放在buffer指针所指向的字符数组中.换行符不作为读取串的内容,读取的换行符 ...