結果

問題 No.723 2つの数の和
ユーザー 👑 rin204rin204
提出日時 2020-06-30 15:52:54
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 191 ms / 2,000 ms
コード長 341 bytes
コンパイル時間 102 ms
コンパイル使用メモリ 10,540 KB
実行使用メモリ 19,780 KB
最終ジャッジ日時 2023-10-01 01:29:38
合計ジャッジ時間 4,927 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,892 KB
testcase_01 AC 16 ms
7,980 KB
testcase_02 AC 16 ms
7,892 KB
testcase_03 AC 140 ms
15,776 KB
testcase_04 AC 191 ms
19,016 KB
testcase_05 AC 168 ms
17,744 KB
testcase_06 AC 177 ms
17,980 KB
testcase_07 AC 81 ms
12,320 KB
testcase_08 AC 92 ms
13,312 KB
testcase_09 AC 187 ms
19,144 KB
testcase_10 AC 83 ms
12,348 KB
testcase_11 AC 28 ms
9,100 KB
testcase_12 AC 105 ms
14,120 KB
testcase_13 AC 189 ms
19,644 KB
testcase_14 AC 53 ms
10,616 KB
testcase_15 AC 83 ms
12,564 KB
testcase_16 AC 119 ms
15,064 KB
testcase_17 AC 158 ms
17,480 KB
testcase_18 AC 146 ms
10,004 KB
testcase_19 AC 166 ms
19,780 KB
testcase_20 AC 16 ms
7,944 KB
testcase_21 AC 16 ms
7,992 KB
testcase_22 AC 16 ms
7,944 KB
testcase_23 AC 172 ms
19,736 KB
testcase_24 AC 62 ms
11,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect_right, bisect_left

n, x = map(int, input().split())
alst = list(map(int, input().split()))
alst.sort()

ans = 0
for num in alst:
    tmp = x - num
    if num == tmp:
        ans += bisect_right(alst, tmp) - bisect_left(alst, tmp)
    else:
        ans += bisect_right(alst, tmp) - bisect_left(alst, tmp)
print(ans)
0