No.723 Sum of Two Numbers
Problem Statement
You are given a sequence $a$ of length $N$ and a non-negative integer $X$.
Find the number of pairs $(i, j)$ satisfying $a_i+a_j=X$.
Input
$N$ $X$ $a_1$ $a_2$ $.$ $.$ $.$ $a_N$
Line $1$ contains the length $N$ of the sequence and the non-negative integer $X$, separated by a space.
Line $2$ contains the $N$ elements of the sequence $a$, separated by spaces.
Constraints
- $1\le N\le 10^5$
- $0\le X\le 10^9$
- $0\le a_i\le 10^5\ (1\le i\le N)$
- All input values are integers.
Output
Print the number of pairs $(i, j)$ satisfying the condition on $1$ line. End the output with a newline.
Sample
Sample 1
Input
3 4 1 2 3
Output
3
The pairs satisfying the condition are the following $3$: $(i, j)=(1, 3), (2, 2), (3,1)$.
Sample 2
Input
4 6 2 4 4 3
Output
5
The pairs satisfying the condition are the following $5$: $(i, j)=(1, 2), (1, 3), (2, 1), (3, 1), (4, 4)$.
Sample 3
Input
4 5 1 2 0 6
Output
0
There is no pair $(i, j)$ satisfying the condition.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
ikd
はむこ