日本レジストリサービス(JPRS)プログラミングコンテスト2025#1(AtCoder Beginner Contest 392)
翻译中…
Problem Statement
翻译中…
For integers $A, B, C$ ( $A < B < C$ ), if they satisfy $B-A = C-B$, then $(A, B, C)$ is called a fine triplet.
You are given a set of $N$ distinct positive integers $S = \{ S_1, S_2, \dots, S_N \}$. Find the number of fine triplets $(A, B, C)$ with $A, B, C \in S$.
翻译中…
Constraints
翻译中…
- All input values are integers.
$1 \le N \le 10^6$$1 \le S_i \le 10^6$- The elements of
$S$are distinct.
翻译中…
Input
翻译中…
The input is given from Standard Input in the following format:
翻译中…
N
S_1 S_2 \dots S_N
翻译中…
Output
翻译中…
Print the number of fine triplets as an integer.
翻译中…
样例
Input #1
5
8 3 1 5 2
Output #1
3
Here, $S = \{8,3,1,5,2\}$. The fine triplets to be counted are the following three:
- $(1,2,3)$
- $(1,3,5)$
- $(2,5,8)$
Input #2
7
300000 100000 499998 499999 200000 400000 500000
Output #2
5
Input #3
10
13 1 16 15 12 4 7 10 2 19
Output #3
10
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。