問題一覧 > 通常問題

No.3392 Count 23578 Sequence

レベル : / AI推定難易度 : 1600 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 47
作問者 : yu23578 / テスター : GaLLium yt142857 aa36 Germanium32
お気に入りにしたユーザー ProblemId : 12765 / 自分の提出
問題文最終更新日: 2025-11-28 21:42:59
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 490 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。