結果

問題 No.723 2つの数の和
ユーザー YoteichiYoteichi
提出日時 2018-08-04 04:10:26
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 301 bytes
コンパイル時間 309 ms
コンパイル使用メモリ 11,928 KB
実行使用メモリ 38,792 KB
最終ジャッジ日時 2023-10-19 21:42:34
合計ジャッジ時間 4,718 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 89 ms
16,108 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 197 ms
32,928 KB
testcase_14 AC 116 ms
19,520 KB
testcase_15 AC 137 ms
24,452 KB
testcase_16 AC 156 ms
27,340 KB
testcase_17 AC 177 ms
26,188 KB
testcase_18 AC 140 ms
23,260 KB
testcase_19 AC 143 ms
23,612 KB
testcase_20 AC 88 ms
16,108 KB
testcase_21 AC 85 ms
16,108 KB
testcase_22 AC 85 ms
16,108 KB
testcase_23 WA -
testcase_24 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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
if table[x.fdiv(2)]
    count += table[x.fdiv(2)]**2
end
table.keys.each do |k|
    if x - k < 0
        next
    end
    count = table[k] * (table[x - k] || 0)
end
puts count
0