結果

問題 No.723 2つの数の和
ユーザー brthyyjpbrthyyjp
提出日時 2020-03-30 04:07:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 107 ms / 2,000 ms
コード長 281 bytes
コンパイル時間 489 ms
コンパイル使用メモリ 87,304 KB
実行使用メモリ 104,684 KB
最終ジャッジ日時 2023-08-30 20:16:22
合計ジャッジ時間 4,029 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,456 KB
testcase_01 AC 71 ms
71,188 KB
testcase_02 AC 68 ms
71,440 KB
testcase_03 AC 99 ms
92,600 KB
testcase_04 AC 107 ms
99,164 KB
testcase_05 AC 103 ms
97,680 KB
testcase_06 AC 105 ms
97,620 KB
testcase_07 AC 87 ms
84,624 KB
testcase_08 AC 91 ms
85,796 KB
testcase_09 AC 106 ms
99,500 KB
testcase_10 AC 87 ms
83,984 KB
testcase_11 AC 76 ms
76,660 KB
testcase_12 AC 94 ms
88,156 KB
testcase_13 AC 107 ms
99,404 KB
testcase_14 AC 82 ms
80,452 KB
testcase_15 AC 88 ms
84,932 KB
testcase_16 AC 94 ms
91,324 KB
testcase_17 AC 102 ms
96,652 KB
testcase_18 AC 91 ms
89,424 KB
testcase_19 AC 94 ms
90,764 KB
testcase_20 AC 70 ms
71,276 KB
testcase_21 AC 68 ms
71,420 KB
testcase_22 AC 69 ms
71,384 KB
testcase_23 AC 107 ms
104,684 KB
testcase_24 AC 85 ms
81,780 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, x = map(int, input().split())
A = list(map(int, input().split()))
d = {}
ans = 0
for a in A:
    if a not in d:
        d[a] = 1
    else:
        d[a] += 1
    if x-a in d:
        if a != x-a:
            ans += 2*d[x-a]
        else:
            ans += 2*d[x-a]-1
print(ans)
0