結果

問題 No.723 2つの数の和
ユーザー GrayCoderGrayCoder
提出日時 2018-08-03 23:15:02
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 184 ms / 2,000 ms
コード長 386 bytes
コンパイル時間 705 ms
コンパイル使用メモリ 11,872 KB
実行使用メモリ 21,556 KB
最終ジャッジ日時 2023-10-19 21:39:32
合計ジャッジ時間 3,704 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,032 KB
testcase_01 AC 31 ms
10,032 KB
testcase_02 AC 30 ms
10,032 KB
testcase_03 AC 140 ms
17,592 KB
testcase_04 AC 184 ms
21,224 KB
testcase_05 AC 164 ms
19,576 KB
testcase_06 AC 174 ms
19,720 KB
testcase_07 AC 88 ms
14,096 KB
testcase_08 AC 96 ms
15,124 KB
testcase_09 AC 181 ms
21,332 KB
testcase_10 AC 85 ms
14,200 KB
testcase_11 AC 41 ms
11,024 KB
testcase_12 AC 107 ms
15,944 KB
testcase_13 AC 184 ms
21,468 KB
testcase_14 AC 61 ms
12,576 KB
testcase_15 AC 89 ms
14,476 KB
testcase_16 AC 122 ms
16,884 KB
testcase_17 AC 156 ms
19,220 KB
testcase_18 AC 139 ms
11,828 KB
testcase_19 AC 158 ms
21,556 KB
testcase_20 AC 31 ms
10,032 KB
testcase_21 AC 31 ms
10,032 KB
testcase_22 AC 30 ms
10,032 KB
testcase_23 AC 162 ms
21,532 KB
testcase_24 AC 69 ms
13,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect, bisect_left
from sys import stdin, stdout
input = lambda: stdin.readline().rstrip()
write = stdout.write

def main():
    N, X = map(int, input().split())
    A = list(map(int, input().split()))

    A.sort()
    ans = 0
    for ai in A:
        aj = X - ai
        i = bisect_left(A, aj)
        j = bisect(A, aj)
        ans += j - i
    print(ans)

main()
0