結果

問題 No.723 2つの数の和
ユーザー O2MTO2MT
提出日時 2020-08-21 18:01:36
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 197 ms / 2,000 ms
コード長 261 bytes
コンパイル時間 91 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 20,884 KB
最終ジャッジ日時 2024-04-23 05:11:09
合計ジャッジ時間 3,573 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,752 KB
testcase_01 AC 31 ms
10,880 KB
testcase_02 AC 30 ms
10,880 KB
testcase_03 AC 133 ms
17,304 KB
testcase_04 AC 180 ms
20,000 KB
testcase_05 AC 146 ms
19,224 KB
testcase_06 AC 167 ms
19,116 KB
testcase_07 AC 81 ms
14,452 KB
testcase_08 AC 92 ms
15,124 KB
testcase_09 AC 163 ms
20,884 KB
testcase_10 AC 81 ms
14,388 KB
testcase_11 AC 40 ms
11,648 KB
testcase_12 AC 100 ms
15,880 KB
testcase_13 AC 153 ms
20,680 KB
testcase_14 AC 55 ms
13,056 KB
testcase_15 AC 77 ms
14,684 KB
testcase_16 AC 102 ms
16,944 KB
testcase_17 AC 126 ms
18,788 KB
testcase_18 AC 158 ms
12,636 KB
testcase_19 AC 193 ms
20,868 KB
testcase_20 AC 29 ms
10,752 KB
testcase_21 AC 31 ms
10,752 KB
testcase_22 AC 30 ms
10,880 KB
testcase_23 AC 197 ms
20,668 KB
testcase_24 AC 62 ms
13,440 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import *
N,X = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
ans = 0
for i in range(N):
  b = bisect_left(A,X-A[i])
  if b >= N:
    continue
  if A[i]+A[b] == X:
    br = bisect_right(A,X-A[i])
    ans += (br-b)
print(ans)
  
0