結果

問題 No.120 傾向と対策:門松列(その1)
ユーザー kurenai3110kurenai3110
提出日時 2017-01-31 20:43:28
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 181 ms / 5,000 ms
コード長 518 bytes
コンパイル時間 99 ms
コンパイル使用メモリ 10,936 KB
実行使用メモリ 8,328 KB
最終ジャッジ日時 2023-08-25 16:05:24
合計ジャッジ時間 1,410 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
7,792 KB
testcase_01 AC 181 ms
7,824 KB
testcase_02 AC 86 ms
8,328 KB
testcase_03 AC 181 ms
7,808 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

t = int(input())
for i in range(t):
    n = int(input())
    L = list(map(int,input().split()))
    Lunique = list(set(L))
    if len(Lunique)<=2:
        print(0)
        continue

    cnt = [L.count(lu) for lu in Lunique]
    cnt.sort(reverse=True)

    ans=0
    while 1:
        for i in range(3):
            if cnt[i]==0:
                break
            cnt[i]-=1
        else:
            cnt.sort(reverse=True)
            ans+=1
            continue
        break

    print(ans)
            
        
    
0