結果

問題 No.723 2つの数の和
ユーザー takakintakakin
提出日時 2020-04-24 02:01:57
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 135 ms / 2,000 ms
コード長 248 bytes
コンパイル時間 273 ms
コンパイル使用メモリ 10,704 KB
実行使用メモリ 23,060 KB
最終ジャッジ日時 2023-08-04 14:01:40
合計ジャッジ時間 3,147 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,496 KB
testcase_01 AC 17 ms
8,520 KB
testcase_02 AC 17 ms
8,520 KB
testcase_03 AC 105 ms
21,932 KB
testcase_04 AC 126 ms
22,944 KB
testcase_05 AC 115 ms
22,456 KB
testcase_06 AC 120 ms
22,924 KB
testcase_07 AC 67 ms
16,476 KB
testcase_08 AC 72 ms
17,816 KB
testcase_09 AC 132 ms
23,028 KB
testcase_10 AC 61 ms
16,332 KB
testcase_11 AC 27 ms
10,004 KB
testcase_12 AC 78 ms
16,736 KB
testcase_13 AC 135 ms
23,056 KB
testcase_14 AC 45 ms
12,420 KB
testcase_15 AC 66 ms
16,500 KB
testcase_16 AC 95 ms
21,720 KB
testcase_17 AC 112 ms
22,112 KB
testcase_18 AC 86 ms
9,968 KB
testcase_19 AC 110 ms
19,636 KB
testcase_20 AC 18 ms
8,580 KB
testcase_21 AC 17 ms
8,416 KB
testcase_22 AC 18 ms
8,500 KB
testcase_23 AC 119 ms
23,060 KB
testcase_24 AC 55 ms
15,204 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