結果

問題 No.120 傾向と対策:門松列(その1)
ユーザー gorugo30gorugo30
提出日時 2021-03-05 18:26:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 149 ms / 5,000 ms
コード長 522 bytes
コンパイル時間 303 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 77,184 KB
最終ジャッジ日時 2024-04-16 06:32:54
合計ジャッジ時間 1,483 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 142 ms
77,184 KB
testcase_01 AC 149 ms
76,800 KB
testcase_02 AC 122 ms
76,928 KB
testcase_03 AC 149 ms
76,672 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

T = int(input())
for case in range(T):
    N = int(input())
    L = list(map(int, input().split()))
    rem = []
    app = set()
    for i in range(N):
        if L[i] not in app:
            app.add(L[i])
            rem.append(L.count(L[i]))
    rem.sort(reverse = True)
    if len(rem) < 3:
        print(0)
        continue
    ans = 0
    while True:
        if rem[2] <= 0:
            break
        ans += 1
        rem[0] -= 1
        rem[1] -= 1
        rem[2] -= 1
        rem.sort(reverse = True)
    print(ans)
0