P5650 Basic String Practice Problem.
Background
YSGH is awesome.
Description
Given a non-empty binary string $S$ with non-zero length.
Find a non-empty contiguous substring $T$ of $S$ such that the number of $0$ in the substring minus the number of $1$ in the substring is maximized.
You only need to output this maximum value.
Input Format
One line containing a binary string representing $S$.
Output Format
One line containing one number representing the answer.
Explanation/Hint
Let $|S| = n$.
# Constraints
| Test Point ID | $n \le$ |
| :--: | :--: |
| $1 \sim 2$ | $10$ |
| $3 \sim 6$ | ${10}^3$ |
| $7 \sim 10$ | ${10}^5$ |
For $100\%$ of the testdata, $1 \le n \le {10}^5$.
Translated by ChatGPT 5