結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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
    h1 = h1.sort_by{ |key, val| -val}
    while true do
        count = 0
        find = false
        h1.length.times do |k|
            if h1[k][1] <= 0
                next
            end
            h1[k][1] -= 1
            count += 1
            if count >= 3
                res += 1
                find = true
                break
            end
        end
        if !find
            break
        end
    end
    puts res
end
0