結果

問題 No.723 2つの数の和
コンテスト
ユーザー Theta
提出日時 2022-10-18 14:58:53
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
RE  
実行時間 -
コード長 521 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 546 ms
コンパイル使用メモリ 20,696 KB
実行使用メモリ 29,040 KB
最終ジャッジ日時 2026-03-18 05:17:40
合計ジャッジ時間 6,496 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 RE * 1
other AC * 6 RE * 16
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from collections import defaultdict


def main():
    N, X = map(int, input().split())
    A = list(map(int, input().split()))
    A.sort()
    counter_A = defaultdict(int)

    for num in A:
        counter_A[num] += 1

    patterns = 0
    for num in counter_A:
        if num > X - num:
            break

        if num == X - num:
            patterns += counter_A[num] ** 2
            break

        patterns += counter_A[num] * counter_A[X - num] * 2

    print(patterns)


if __name__ == "__main__":
    main()
0