問題一覧 > 通常問題

No.723 Sum of Two Numbers

レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 380
作問者 : 👑 ikd / テスター : はむこ
お気に入りにしたユーザー ProblemId : 1842 / 自分の提出
問題文最終更新日: 2026-06-25 15:03:29
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 197 (順位表) の他の問題:

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