AtCoder Regular Contest 137
翻译中…
Problem Statement
翻译中…
You are given an integer sequence of length $N$ consisting of $0$ and $1$: $A=(A_1,A_2,\cdots,A_N)$.
翻译中…
You will do the operation below exactly once.
翻译中…
- Choose a contiguous subsequence of
$A$and flip the elements in it: convert$0$to$1$and vice versa. Here, you may choose an empty subsequence, in which case the elements of$A$do not change.
翻译中…
Your score will be the number of $1$'s in $A$. How many values are there that your score can take?
翻译中…
Constraints
翻译中…
$1 \leq N \leq 3 \times 10^5$$0 \leq A_i \leq 1$- All values in input are integers.
翻译中…
Input
翻译中…
Input is given from Standard Input in the following format:
翻译中…
N
A_1 A_2 \cdots A_N
翻译中…
Output
翻译中…
Print the answer.
翻译中…
样例
Input #1
4
0 1 1 0
Output #1
4
There are four possible values for your score: $0, 1, 2, 3$. For example, if you flip the $2$-nd through $4$-th elements of $A$, you will get $A=(0,0,0,1)$, for a score of $1$.
Input #2
5
0 0 0 0 0
Output #2
6
Input #3
6
0 1 0 1 0 1
Output #3
3
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。