結果

問題 No.29 パワーアップ
ユーザー gemmaro
提出日時 2019-10-25 19:33:42
言語 Ruby
(3.4.1)
結果
AC  
実行時間 98 ms / 5,000 ms
コード長 321 bytes
コンパイル時間 53 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 12,288 KB
最終ジャッジ日時 2024-07-21 16:42:07
合計ジャッジ時間 2,982 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n = gets.chomp.to_i

items = {}
n.times {
    a, b, c = gets.chomp.split.map &:to_i
    items[a] ||= 0
    items[b] ||= 0
    items[c] ||= 0
    items[a] += 1
    items[b] += 1
    items[c] += 1
}

power_up = 0
remain = 0
items.each {|_, value|
    power_up += value / 2
    remain += value % 2
}

p power_up + remain / 4
0