atcoder#ARC137B. [ARC137B] Count 1's
[ARC137B] Count 1's
Score : points
Problem Statement
You are given an integer sequence of length consisting of and : .
You will do the operation below exactly once.
- Choose a contiguous subsequence of and flip the elements in it: convert to and vice versa. Here, you may choose an empty subsequence, in which case the elements of do not change.
Your score will be the number of 's in . How many values are there that your score can take?
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
4
0 1 1 0
4
There are four possible values for your score: . For example, if you flip the -nd through -th elements of , you will get , for a score of .
5
0 0 0 0 0
6
6
0 1 0 1 0 1
3