結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 86 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 206 ms
32,928 KB
testcase_14 AC 117 ms
19,528 KB
testcase_15 AC 142 ms
24,456 KB
testcase_16 AC 160 ms
27,344 KB
testcase_17 AC 187 ms
26,192 KB
testcase_18 AC 139 ms
23,264 KB
testcase_19 AC 142 ms
23,548 KB
testcase_20 AC 86 ms
16,108 KB
testcase_21 AC 86 ms
16,108 KB
testcase_22 AC 86 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)]
    if table[x/2] == 1
        count += 1
    else
        count += table[x/2]**2 - table[x/2]
    end
end
table.keys.each do |k|
    if table[x.fdiv(2)] && table[x/2] == k
        break
    end
    if x - k < 0
        next
    end
    count = table[k] * (table[x - k] || 0)
end
puts count
0