結果

問題 No.723 2つの数の和
ユーザー YoteichiYoteichi
提出日時 2018-08-04 05:31:22
言語 Ruby
(3.3.0)
結果
AC  
実行時間 225 ms / 2,000 ms
コード長 207 bytes
コンパイル時間 39 ms
コンパイル使用メモリ 11,916 KB
実行使用メモリ 38,152 KB
最終ジャッジ日時 2023-10-19 21:44:35
合計ジャッジ時間 4,503 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
16,060 KB
testcase_01 AC 92 ms
16,060 KB
testcase_02 AC 86 ms
16,060 KB
testcase_03 AC 164 ms
24,796 KB
testcase_04 AC 189 ms
31,416 KB
testcase_05 AC 174 ms
26,112 KB
testcase_06 AC 185 ms
26,588 KB
testcase_07 AC 132 ms
23,004 KB
testcase_08 AC 137 ms
24,596 KB
testcase_09 AC 192 ms
32,080 KB
testcase_10 AC 132 ms
22,708 KB
testcase_11 AC 97 ms
16,944 KB
testcase_12 AC 145 ms
25,544 KB
testcase_13 AC 195 ms
32,352 KB
testcase_14 AC 114 ms
19,208 KB
testcase_15 AC 134 ms
24,136 KB
testcase_16 AC 154 ms
27,024 KB
testcase_17 AC 177 ms
25,864 KB
testcase_18 AC 140 ms
23,208 KB
testcase_19 AC 142 ms
23,560 KB
testcase_20 AC 86 ms
16,060 KB
testcase_21 AC 86 ms
16,056 KB
testcase_22 AC 88 ms
16,060 KB
testcase_23 AC 225 ms
38,152 KB
testcase_24 AC 121 ms
21,056 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:1: warning: assigned but unused variable - n
Syntax OK

ソースコード

diff #

n, x = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
table = a.group_by(&:itself).map { |k,v| [k,v.size] }.to_h
count = 0
table.each_key do |k|
    count += table[k] * (table[x - k] || 0)
end
puts count
0