結果

問題 No.723 2つの数の和
ユーザー syunsukesyunsuke
提出日時 2019-05-24 23:40:48
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 303 ms / 2,000 ms
コード長 553 bytes
コンパイル時間 101 ms
コンパイル使用メモリ 11,912 KB
実行使用メモリ 22,376 KB
最終ジャッジ日時 2023-10-17 15:06:45
合計ジャッジ時間 4,277 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,128 KB
testcase_01 AC 29 ms
10,128 KB
testcase_02 AC 30 ms
10,128 KB
testcase_03 AC 161 ms
17,696 KB
testcase_04 AC 204 ms
21,260 KB
testcase_05 AC 176 ms
19,680 KB
testcase_06 AC 194 ms
19,824 KB
testcase_07 AC 95 ms
15,788 KB
testcase_08 AC 107 ms
16,472 KB
testcase_09 AC 188 ms
20,892 KB
testcase_10 AC 95 ms
15,768 KB
testcase_11 AC 41 ms
11,600 KB
testcase_12 AC 115 ms
16,092 KB
testcase_13 AC 181 ms
21,576 KB
testcase_14 AC 65 ms
15,284 KB
testcase_15 AC 93 ms
15,968 KB
testcase_16 AC 128 ms
17,108 KB
testcase_17 AC 154 ms
19,324 KB
testcase_18 AC 73 ms
11,936 KB
testcase_19 AC 87 ms
21,660 KB
testcase_20 AC 29 ms
10,128 KB
testcase_21 AC 29 ms
10,128 KB
testcase_22 AC 29 ms
10,128 KB
testcase_23 AC 303 ms
22,376 KB
testcase_24 AC 74 ms
15,544 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect
N,X=map(int,input().split())

a=list(map(int,input().split()))

c=set(a)
b=list(c)
b.sort()
#print(b)

L=[0 for i in range(len(b))]

for i in range(N):
    L[bisect.bisect_left(b,a[i])]+=1
#print(L)
ans=0
ans2=0
for i in range(len(b)):
    if b[i]*2==X:
        ans2+=L[bisect.bisect_left(b,b[i])]**2
    else:
        if (X-b[i]) in c:
            ans+=L[bisect.bisect_left(b,b[i])]*L[bisect.bisect_left(b,X-b[i])]
            #print(L[bisect.bisect_left(b,b[i])],L[bisect.bisect_left(b,X-b[i])])
print(ans+ans2)
#print(ans,ans2)
        
0