#C11858. Minimum Operations to Remove Consecutive Ones
Minimum Operations to Remove Consecutive Ones
Minimum Operations to Remove Consecutive Ones
Given a binary string S
consisting only of '0's and '1's, determine the minimum number of operations required to eliminate all occurrences of consecutive '1's. In each operation, you can remove one occurrence from a pair of consecutive '1's. The final string should not contain any pair of consecutive '1's.
If the string already does not contain any two consecutive '1's, the answer is 0.
Note: In this problem, the solution is implemented by counting each adjacent pair of '1's in the string. For example, for the input 11111
, there are 4 adjacent pairs, so the minimum number of operations required is 4.
inputFormat
The input consists of a single line containing a binary string S
(only characters '0' and '1') read from standard input.
outputFormat
Output a single integer representing the minimum number of operations required, printed to standard output.
## sample1010101
0