結果

問題 No.723 2つの数の和
ユーザー gemmarogemmaro
提出日時 2020-04-25 09:28:22
言語 Ruby
(3.3.0)
結果
AC  
実行時間 181 ms / 2,000 ms
コード長 211 bytes
コンパイル時間 194 ms
コンパイル使用メモリ 11,416 KB
実行使用メモリ 27,156 KB
最終ジャッジ日時 2023-08-06 14:16:16
合計ジャッジ時間 5,169 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 90 ms
15,128 KB
testcase_01 AC 86 ms
15,108 KB
testcase_02 AC 83 ms
15,204 KB
testcase_03 AC 146 ms
22,116 KB
testcase_04 AC 173 ms
24,300 KB
testcase_05 AC 157 ms
23,144 KB
testcase_06 AC 162 ms
23,588 KB
testcase_07 AC 121 ms
19,012 KB
testcase_08 AC 127 ms
20,328 KB
testcase_09 AC 175 ms
24,548 KB
testcase_10 AC 117 ms
18,644 KB
testcase_11 AC 90 ms
15,524 KB
testcase_12 AC 133 ms
20,796 KB
testcase_13 AC 178 ms
24,996 KB
testcase_14 AC 103 ms
17,588 KB
testcase_15 AC 120 ms
20,252 KB
testcase_16 AC 137 ms
21,376 KB
testcase_17 AC 152 ms
23,020 KB
testcase_18 AC 153 ms
22,368 KB
testcase_19 AC 158 ms
23,192 KB
testcase_20 AC 83 ms
15,272 KB
testcase_21 AC 83 ms
15,104 KB
testcase_22 AC 84 ms
15,004 KB
testcase_23 AC 181 ms
27,156 KB
testcase_24 AC 111 ms
18,008 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

# frozen_string_literal: true

N, X = gets.chomp.split.map(&:to_i)
A = gets.chomp.split.map(&:to_i)

c = {}
A.each do |a|
  c[a] ||= 0
  c[a] += 1
end
C = c

RESULT = A.map { |a| C[X - a] || 0 }.sum

puts RESULT
0