結果

問題 No.723 2つの数の和
ユーザー roknaoroknao
提出日時 2019-10-28 15:54:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 169 ms / 2,000 ms
コード長 357 bytes
コンパイル時間 291 ms
コンパイル使用メモリ 87,044 KB
実行使用メモリ 90,748 KB
最終ジャッジ日時 2023-10-12 23:06:00
合計ジャッジ時間 4,957 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
70,952 KB
testcase_01 AC 75 ms
71,172 KB
testcase_02 AC 74 ms
71,088 KB
testcase_03 AC 143 ms
85,432 KB
testcase_04 AC 166 ms
90,168 KB
testcase_05 AC 150 ms
88,328 KB
testcase_06 AC 169 ms
88,620 KB
testcase_07 AC 119 ms
80,804 KB
testcase_08 AC 123 ms
81,424 KB
testcase_09 AC 151 ms
90,748 KB
testcase_10 AC 123 ms
80,620 KB
testcase_11 AC 95 ms
77,096 KB
testcase_12 AC 136 ms
83,244 KB
testcase_13 AC 145 ms
90,160 KB
testcase_14 AC 100 ms
78,396 KB
testcase_15 AC 109 ms
81,352 KB
testcase_16 AC 124 ms
84,192 KB
testcase_17 AC 137 ms
88,468 KB
testcase_18 AC 126 ms
88,900 KB
testcase_19 AC 129 ms
90,060 KB
testcase_20 AC 74 ms
71,308 KB
testcase_21 AC 74 ms
70,956 KB
testcase_22 AC 73 ms
71,052 KB
testcase_23 AC 161 ms
90,116 KB
testcase_24 AC 106 ms
79,276 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect
import sys
input = sys.stdin.readline


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

    ans = 0
    for i in range(N):
        r = bisect.bisect_right(A, X-A[i])
        l = bisect.bisect_left(A, X-A[i])
        ans += r - l
    
    print(ans)


if __name__ == '__main__':
    main()
0