#K66807. Minimum Operations to Convert Binary Array to Zeros
Minimum Operations to Convert Binary Array to Zeros
Minimum Operations to Convert Binary Array to Zeros
You are given a binary array of size \( n \) consisting only of 0's and 1's. In a single operation, you can select any contiguous segment of 1's (i.e. a maximal subarray where every element is 1) and change all of them to 0's. Your task is to determine the minimum number of operations required to turn the entire array into zeros.
Note: The answer is equivalent to the number of contiguous segments of 1's in the array.
inputFormat
The input consists of two lines. The first line contains a single integer \( n \) (\( 1 \leq n \leq 10^5 \)), representing the number of elements in the array. The second line contains \( n \) space-separated integers, each being either 0 or 1.
outputFormat
Output a single integer denoting the minimum number of operations required to convert the entire array to zeros.
## sample3
0 0 0
0