No.3392 Count 23578 Sequence
タグ : / 解いたユーザー数 47
作問者 :
yt142857
Germanium32
What Is a 23578 Sequence (this definition is the same as in Problem A)
Let $A$ be a sequence of positive integers of length $N$. If, for every integer $i\ (1 \le i \le N)$, $$A_i + A_{N-i+1} = A_1 + A_N$$ holds, then $A$ is called a "23578 sequence".
Problem Statement
You are given a sequence $A$ of positive integers of length $N$. Find the total number of contiguous subarrays of $A$ that are 23578 sequences.
Constraints
- $1 \le N \le 10^6$
- $1 \le A_i \le 10^9$
- All input values are integers.
Input
$N$ $A_1\ A_2\ A_3 \cdots\ A_N$
Output
Print the total number of contiguous subarrays of $A$ that are 23578 sequences.
Print a newline at the end.
Sample
Sample 1
Input
3 3 1 4
Output
5
The contiguous subarrays of $A = (3,1,4)$ that are 23578 sequences are the following
$(A_1) = (3)$
$(A_2) = (1)$
$(A_3) = (4)$
$(A_1,A_2) = (3,1)$
$(A_2,A_3) = (1,4)$
for a total of $5$.
Sample 2
Input
5 2 3 5 7 8
Output
11
Sample 3
Input
5 1000000000 1000000000 1000000000 1000000000 1000000000
Output
15
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。