codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

567B.md (2873B)


      1 Source: https://codeforces.com/problemset/problem/567/B
      2 
      3 B. Berland National Library
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 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.
     22 
     23 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 a registration 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:
     24 
     25 * "+ *r**i*" — the reader with registration number *r**i* entered the room;
     26 * "- *r**i*" — the reader with registration number *r**i* left the room.
     27 
     28 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.
     29 
     30 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.
     31 
     32 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.
     33 
     34 Input
     35 
     36 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 "+ *r**i*" or "- *r**i*", where *r**i* is an integer from 1 to 106, the registration number of the visitor (that is, distinct visitors always have distinct registration numbers).
     37 
     38 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.
     39 
     40 Output
     41 
     42 Print a single integer — the minimum possible capacity of the reading room.
     43 
     44 Examples
     45 
     46 Input
     47 
     48 ```
     49 6  
     50 + 12001  
     51 - 12001  
     52 - 1  
     53 - 1200  
     54 + 1  
     55 + 7
     56 ```
     57 
     58 Output
     59 
     60 ```
     61 3
     62 ```
     63 
     64 Input
     65 
     66 ```
     67 2  
     68 - 1  
     69 - 2
     70 ```
     71 
     72 Output
     73 
     74 ```
     75 2
     76 ```
     77 
     78 Input
     79 
     80 ```
     81 2  
     82 + 1  
     83 - 1
     84 ```
     85 
     86 Output
     87 
     88 ```
     89 1
     90 ```
     91 
     92 Note
     93 
     94 In the first sample test, the system log will ensure that at some point in the reading room were visitors with registration numbers 1, 1200 and 12001. More people were not in the room at the same time based on the log. Therefore, the answer to the test is 3.