結果

問題 No.29 パワーアップ
ユーザー hashimoto
提出日時 2015-07-29 16:47:52
言語 Ruby
(3.4.1)
結果
AC  
実行時間 84 ms / 5,000 ms
コード長 483 bytes
コンパイル時間 99 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 12,160 KB
最終ジャッジ日時 2024-07-17 22:06:46
合計ジャッジ時間 2,794 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n = gets.to_i
items = Array.new(n * 3)

n.times do | i |
    items[3 * i], items[3 * i + 1], items[3 * i + 2] = gets.split.map(&:to_i)
end

items.sort!()
powerup_count = 0
tmp = -1

items.length.times do | j |
    if j == 0
        tmp = items[j]
        next
    end
    if tmp == items[j]
        items[j] = '*'
        items[j - 1] = '*'
        powerup_count += 1
        tmp = -1
    else
        tmp = items[j]
    end
end

items.delete('*')
p powerup_count += items.length / 4
0