AtCoder Beginner Contest 052
翻译中…
Problem Statement
翻译中…
You have an integer variable $x$. Initially, $x=0$.
翻译中…
Some person gave you a string $S$ of length $N$, and using the string you performed the following operation $N$ times. In the $i$-th operation, you incremented the value of $x$ by $1$ if $S_i=$I, and decremented the value of $x$ by $1$ if $S_i=$D.
翻译中…
Find the maximum value taken by $x$ during the operations (including before the first operation, and after the last operation).
翻译中…
Constraints
翻译中…
$1≤N≤100$$|S|=N$- No characters except
IandDoccur in$S$.
翻译中…
Input
翻译中…
The input is given from Standard Input in the following format:
翻译中…
N
S
翻译中…
Output
翻译中…
Print the maximum value taken by $x$ during the operations.
翻译中…
样例
Input #1
5
IIDID
Output #1
2
After each operation, the value of $x$ becomes $1$, $2$, $1$, $2$ and $1$, respectively. Thus, the output should be $2$, the maximum value.
Input #2
7
DDIDDII
Output #2
0
The initial value $x=0$ is the maximum value taken by $x$, thus the output should be $0$.
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。