結果

問題 No.120 傾向と対策:門松列(その1)
ユーザー kutsutamakutsutama
提出日時 2019-01-14 03:44:46
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 113 ms / 5,000 ms
コード長 625 bytes
コンパイル時間 98 ms
コンパイル使用メモリ 10,896 KB
実行使用メモリ 8,688 KB
最終ジャッジ日時 2023-08-28 18:09:28
合計ジャッジ時間 1,293 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 103 ms
8,688 KB
testcase_01 AC 111 ms
8,604 KB
testcase_02 AC 64 ms
8,688 KB
testcase_03 AC 113 ms
8,588 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections

def solve(N, L):
    c = collections.Counter()
    for Li in L:
        c[Li] += 1
    cnt = list(c.values())

    if len(cnt) < 3:
        return 0

    res = 0
    while True:
        cnt.sort(reverse=True)
        if cnt[0] > 0 and cnt[1] > 0 and cnt[2] > 0:
            res += 1
            cnt[0] -= 1
            cnt[1] -= 1
            cnt[2] -= 1
        else:
            break

    return res


T = int(input())
lis = [0] * T
for tt in range(T):
    nt = int(input())
    lt = [int(x) for x in input().split()]
    lis[tt] = solve(nt, lt)

print(*lis, sep='\n')
0