結果

問題 No.723 2つの数の和
ユーザー neko_the_shadowneko_the_shadow
提出日時 2018-08-03 22:58:15
言語 Ruby
(3.3.0)
結果
AC  
実行時間 177 ms / 2,000 ms
コード長 212 bytes
コンパイル時間 359 ms
コンパイル使用メモリ 11,916 KB
実行使用メモリ 27,432 KB
最終ジャッジ日時 2023-10-19 21:36:11
合計ジャッジ時間 4,458 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
16,084 KB
testcase_01 AC 86 ms
16,084 KB
testcase_02 AC 88 ms
16,084 KB
testcase_03 AC 139 ms
22,644 KB
testcase_04 AC 164 ms
24,540 KB
testcase_05 AC 149 ms
23,580 KB
testcase_06 AC 152 ms
23,864 KB
testcase_07 AC 118 ms
19,712 KB
testcase_08 AC 121 ms
21,072 KB
testcase_09 AC 164 ms
24,660 KB
testcase_10 AC 116 ms
19,384 KB
testcase_11 AC 93 ms
16,608 KB
testcase_12 AC 129 ms
21,488 KB
testcase_13 AC 166 ms
24,972 KB
testcase_14 AC 103 ms
18,480 KB
testcase_15 AC 119 ms
20,864 KB
testcase_16 AC 136 ms
22,148 KB
testcase_17 AC 145 ms
23,344 KB
testcase_18 AC 140 ms
22,164 KB
testcase_19 AC 143 ms
22,652 KB
testcase_20 AC 86 ms
16,084 KB
testcase_21 AC 86 ms
16,084 KB
testcase_22 AC 86 ms
16,084 KB
testcase_23 AC 177 ms
27,432 KB
testcase_24 AC 110 ms
18,684 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:1: warning: assigned but unused variable - n
Syntax OK

ソースコード

diff #

n, x = gets.split.map(&:to_i)
digits = gets.split.map(&:to_i)

table = Hash.new(0)
digits.each{|digit| table[digit] += 1}

cnt = 0
table.keys.each do |digit|
  cnt += table[digit] * table[x - digit]
end

puts cnt
0