結果

問題 No.723 2つの数の和
ユーザー Takuya NoguchiTakuya Noguchi
提出日時 2018-09-24 19:11:44
言語 Ruby
(3.2.2)
結果
AC  
実行時間 165 ms / 2,000 ms
コード長 156 bytes
コンパイル時間 701 ms
コンパイル使用メモリ 11,892 KB
実行使用メモリ 27,452 KB
最終ジャッジ日時 2023-10-23 22:06:54
合計ジャッジ時間 5,583 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
16,104 KB
testcase_01 AC 83 ms
16,104 KB
testcase_02 AC 84 ms
16,104 KB
testcase_03 AC 135 ms
22,664 KB
testcase_04 AC 160 ms
24,560 KB
testcase_05 AC 146 ms
23,492 KB
testcase_06 AC 147 ms
23,776 KB
testcase_07 AC 113 ms
19,572 KB
testcase_08 AC 119 ms
21,092 KB
testcase_09 AC 161 ms
24,680 KB
testcase_10 AC 113 ms
19,404 KB
testcase_11 AC 91 ms
16,628 KB
testcase_12 AC 125 ms
21,508 KB
testcase_13 AC 164 ms
24,884 KB
testcase_14 AC 100 ms
18,500 KB
testcase_15 AC 114 ms
20,884 KB
testcase_16 AC 129 ms
22,168 KB
testcase_17 AC 142 ms
23,364 KB
testcase_18 AC 146 ms
22,184 KB
testcase_19 AC 151 ms
22,672 KB
testcase_20 AC 83 ms
16,104 KB
testcase_21 AC 83 ms
16,104 KB
testcase_22 AC 82 ms
16,104 KB
testcase_23 AC 165 ms
27,452 KB
testcase_24 AC 106 ms
18,704 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N, X = gets.split.map(&:to_i)
hash = Hash.new(0)
a = gets.split.map(&:to_i)

a.each { |ai| hash[ai] += 1 }
puts a.inject(0) { |sum, aj| sum + hash[X - aj] }
0