結果

問題 No.723 2つの数の和
ユーザー Theta
提出日時 2022-10-18 14:58:53
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
RE  
実行時間 -
コード長 521 bytes
コンパイル時間 81 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 25,092 KB
最終ジャッジ日時 2024-06-28 23:04:17
合計ジャッジ時間 2,819 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 RE * 1
other AC * 6 RE * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

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