結果

問題 No.723 2つの数の和
ユーザー nonokai10nonokai10
提出日時 2018-09-30 14:58:03
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 108 ms / 2,000 ms
コード長 241 bytes
コンパイル時間 85 ms
コンパイル使用メモリ 10,668 KB
実行使用メモリ 22,408 KB
最終ジャッジ日時 2023-08-02 13:34:01
合計ジャッジ時間 2,454 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,880 KB
testcase_01 AC 16 ms
7,948 KB
testcase_02 AC 15 ms
7,820 KB
testcase_03 AC 66 ms
17,628 KB
testcase_04 AC 87 ms
18,968 KB
testcase_05 AC 76 ms
17,880 KB
testcase_06 AC 79 ms
18,392 KB
testcase_07 AC 43 ms
14,120 KB
testcase_08 AC 48 ms
14,788 KB
testcase_09 AC 83 ms
19,128 KB
testcase_10 AC 43 ms
13,932 KB
testcase_11 AC 20 ms
9,456 KB
testcase_12 AC 51 ms
14,496 KB
testcase_13 AC 81 ms
19,488 KB
testcase_14 AC 30 ms
11,392 KB
testcase_15 AC 42 ms
14,192 KB
testcase_16 AC 56 ms
17,512 KB
testcase_17 AC 71 ms
17,624 KB
testcase_18 AC 50 ms
10,060 KB
testcase_19 AC 72 ms
19,572 KB
testcase_20 AC 15 ms
7,944 KB
testcase_21 AC 14 ms
7,952 KB
testcase_22 AC 15 ms
7,732 KB
testcase_23 AC 108 ms
22,408 KB
testcase_24 AC 35 ms
12,948 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, x = map(int, input().split())
a = list(map(int, input().split()))
cnt = {}
for i in a:
    if i in cnt:
        cnt[i] += 1
    else:
        cnt[i] = 1

ans = 0

for i in cnt:
    if x-i in cnt:
        ans += cnt[i]*cnt[x-i]

print(ans)
0