結果

問題 No.723 2つの数の和
ユーザー YoteichiYoteichi
提出日時 2018-08-04 04:13:57
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 373 bytes
コンパイル時間 181 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 35,584 KB
最終ジャッジ日時 2024-09-19 17:43:02
合計ジャッジ時間 4,210 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 79 ms
12,032 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 188 ms
29,184 KB
testcase_14 AC 111 ms
16,640 KB
testcase_15 AC 131 ms
20,736 KB
testcase_16 AC 152 ms
24,320 KB
testcase_17 AC 170 ms
26,752 KB
testcase_18 AC 119 ms
19,328 KB
testcase_19 AC 123 ms
19,328 KB
testcase_20 AC 75 ms
12,160 KB
testcase_21 AC 78 ms
12,288 KB
testcase_22 AC 77 ms
12,160 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