結果

問題 No.723 2つの数の和
ユーザー takakintakakin
提出日時 2020-04-24 02:01:57
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 173 ms / 2,000 ms
コード長 248 bytes
コンパイル時間 298 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 25,740 KB
最終ジャッジ日時 2024-04-22 11:39:26
合計ジャッジ時間 3,489 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,752 KB
testcase_01 AC 30 ms
10,624 KB
testcase_02 AC 29 ms
10,752 KB
testcase_03 AC 135 ms
24,052 KB
testcase_04 AC 162 ms
24,748 KB
testcase_05 AC 153 ms
25,288 KB
testcase_06 AC 155 ms
25,064 KB
testcase_07 AC 87 ms
18,420 KB
testcase_08 AC 96 ms
18,992 KB
testcase_09 AC 169 ms
24,940 KB
testcase_10 AC 83 ms
18,476 KB
testcase_11 AC 41 ms
12,288 KB
testcase_12 AC 104 ms
18,740 KB
testcase_13 AC 173 ms
24,816 KB
testcase_14 AC 63 ms
14,800 KB
testcase_15 AC 89 ms
18,388 KB
testcase_16 AC 123 ms
23,628 KB
testcase_17 AC 149 ms
25,424 KB
testcase_18 AC 114 ms
12,492 KB
testcase_19 AC 140 ms
20,720 KB
testcase_20 AC 30 ms
10,752 KB
testcase_21 AC 30 ms
10,752 KB
testcase_22 AC 30 ms
10,752 KB
testcase_23 AC 146 ms
25,740 KB
testcase_24 AC 73 ms
17,324 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=lambda: sys.stdin.readline().rstrip()
n,x=map(int,input().split())
A=[int(i) for i in input().split()]
import collections
D=collections.defaultdict(int)
ans=0
for a in A:
  ans+=2*D[x-a]
  D[a]+=1
  if a*2==x:
    ans+=1
print(ans)
0