#P5650. 基础字符串练习题

基础字符串练习题

Description

Given a non-empty binary string SS with non-zero length.

Find a non-empty contiguous substring TT of SS such that the number of 00 in the substring minus the number of 11 in the substring is maximized.

You only need to output this maximum value.

Input Format

One line containing a binary string representing SS.

Output Format

One line containing one number representing the answer.

0111100101
2

Hint

Let S=n|S| = n.

Constraints

Test Point ID nn \le
121 \sim 2 1010
363 \sim 6 103{10}^3
7107 \sim 10 105{10}^5

For 100%100\% of the testdata, 1n1051 \le n \le {10}^5.

Translated by ChatGPT 5