結果

問題 No.723 2つの数の和
ユーザー letrangerjpletrangerjp
提出日時 2018-08-03 22:51:22
言語 Ruby
(3.3.0)
結果
AC  
実行時間 232 ms / 2,000 ms
コード長 151 bytes
コンパイル時間 167 ms
コンパイル使用メモリ 11,916 KB
実行使用メモリ 38,788 KB
最終ジャッジ日時 2023-10-19 21:33:39
合計ジャッジ時間 4,913 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
16,108 KB
testcase_01 AC 96 ms
16,108 KB
testcase_02 AC 91 ms
16,108 KB
testcase_03 AC 188 ms
25,372 KB
testcase_04 AC 208 ms
31,988 KB
testcase_05 AC 193 ms
26,688 KB
testcase_06 AC 196 ms
27,108 KB
testcase_07 AC 132 ms
23,316 KB
testcase_08 AC 137 ms
24,908 KB
testcase_09 AC 193 ms
32,652 KB
testcase_10 AC 130 ms
22,812 KB
testcase_11 AC 96 ms
17,204 KB
testcase_12 AC 146 ms
26,116 KB
testcase_13 AC 199 ms
32,924 KB
testcase_14 AC 116 ms
19,520 KB
testcase_15 AC 137 ms
24,448 KB
testcase_16 AC 153 ms
27,336 KB
testcase_17 AC 175 ms
26,196 KB
testcase_18 AC 141 ms
23,252 KB
testcase_19 AC 143 ms
23,604 KB
testcase_20 AC 87 ms
16,108 KB
testcase_21 AC 87 ms
16,108 KB
testcase_22 AC 86 ms
16,108 KB
testcase_23 AC 232 ms
38,788 KB
testcase_24 AC 124 ms
21,368 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N, X = gets.split.map &:to_i
A = gets.split.map &:to_i
h = A.group_by(&:itself).map{|k, v|[k, v.size]}.to_h
p h.map{|k, v|
  v * (h[X - k] || 0)
}.sum
0