結果

問題 No.120 傾向と対策:門松列(その1)
ユーザー 小指が強い人小指が強い人
提出日時 2015-11-15 19:18:27
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 590 bytes
コンパイル時間 201 ms
コンパイル使用メモリ 11,380 KB
実行使用メモリ 15,676 KB
最終ジャッジ日時 2023-10-11 16:29:00
合計ジャッジ時間 1,476 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

t = gets.to_i
t.times do 
    n = gets.to_i
    a = gets.split.map(&:to_i)
    h1 = Hash.new(0)
    n.times do |i|
        h1[a[i]] += 1
    end
    res = 0
    count = 0
    while true do
        ch = 0
        h1.each_key do |k|
            if h1[k] <= 0
                next
            end
            h1[k] -= 1
            count += 1
            if h1[k] > 0
                ch += 1
            end
            if count >= 3
                count = 0
                res += 1
            end
        end
        if ch + count < 3
            break
        end
    end
    puts res
end
0