結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 209 ms
32,928 KB
testcase_14 AC 119 ms
19,524 KB
testcase_15 AC 141 ms
24,452 KB
testcase_16 AC 163 ms
27,340 KB
testcase_17 AC 187 ms
26,188 KB
testcase_18 AC 138 ms
23,260 KB
testcase_19 AC 143 ms
23,612 KB
testcase_20 AC 86 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/2]**2 - table[x/2]
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