結果

問題 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
コンパイル時間 184 ms
コンパイル使用メモリ 10,536 KB
実行使用メモリ 19,716 KB
最終ジャッジ日時 2023-10-01 01:29:43
合計ジャッジ時間 3,812 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,900 KB
testcase_01 AC 16 ms
8,036 KB
testcase_02 AC 17 ms
7,908 KB
testcase_03 AC 141 ms
15,804 KB
testcase_04 AC 190 ms
18,856 KB
testcase_05 AC 167 ms
17,580 KB
testcase_06 AC 177 ms
17,844 KB
testcase_07 AC 81 ms
12,224 KB
testcase_08 AC 89 ms
13,164 KB
testcase_09 AC 182 ms
19,024 KB
testcase_10 AC 78 ms
12,416 KB
testcase_11 AC 29 ms
8,964 KB
testcase_12 AC 100 ms
14,112 KB
testcase_13 AC 191 ms
19,492 KB
testcase_14 AC 51 ms
10,512 KB
testcase_15 AC 81 ms
12,700 KB
testcase_16 AC 120 ms
15,056 KB
testcase_17 AC 155 ms
17,464 KB
testcase_18 AC 141 ms
9,908 KB
testcase_19 AC 162 ms
19,680 KB
testcase_20 AC 16 ms
7,892 KB
testcase_21 AC 16 ms
7,884 KB
testcase_22 AC 16 ms
7,976 KB
testcase_23 AC 171 ms
19,716 KB
testcase_24 AC 60 ms
11,220 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