結果

問題 No.120 傾向と対策:門松列(その1)
ユーザー nanaenanae
提出日時 2017-02-10 01:04:47
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 310 ms / 5,000 ms
コード長 680 bytes
コンパイル時間 239 ms
コンパイル使用メモリ 10,900 KB
実行使用メモリ 8,760 KB
最終ジャッジ日時 2023-08-26 23:01:04
合計ジャッジ時間 2,051 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 225 ms
8,532 KB
testcase_01 AC 282 ms
8,560 KB
testcase_02 AC 133 ms
8,760 KB
testcase_03 AC 310 ms
8,728 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from collections import Counter

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def solve():
    T = int(input())

    for i in range(T):
        N = int(input())
        Ls = [int(i) for i in input().split()]
        cnt = Counter(Ls)
        ans = 0

        while len(cnt) >= 3:
            ans += 1
            kdmt = [key for key, value in cnt.most_common(3)]
            for i in kdmt:
                cnt[i] -= 1
                if cnt[i] == 0:
                    del cnt[i]

        print(ans)

if __name__ == '__main__':
    solve()
0