Problems > Peak Occupancy

Peak Occupancy

Difficulty: 900 3000 ms 128 MB

implementation

A log records cars entering (I) and leaving (O) an initially empty car park (the log is consistent). Print the maximum number of cars present at once.

Input: the first line has N; the second line has the N events separated by spaces.

Output: the peak occupancy.

Constraints:

  • 1 ≤ N ≤ 105

Sample Tests

Input 1
6
I I O I I O
Output 1
3
Input 2
1
I
Output 2
1

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.