結果
| 問題 | No.120 傾向と対策:門松列(その1) | 
| コンテスト | |
| ユーザー |  ntuda | 
| 提出日時 | 2024-11-22 18:55:26 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 134 ms / 5,000 ms | 
| コード長 | 482 bytes | 
| コンパイル時間 | 253 ms | 
| コンパイル使用メモリ | 82,176 KB | 
| 実行使用メモリ | 77,076 KB | 
| 最終ジャッジ日時 | 2024-11-22 18:55:28 | 
| 合計ジャッジ時間 | 1,563 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 4 | 
ソースコード
from collections import defaultdict
def check(x):
    n = N
    for v in dic.values():
        if v > x:
            n -= v - x
    return n >= 3 * x
for _ in range(int(input())):
    N = int(input())
    L = list(map(int, input().split()))
    dic = defaultdict(int)
    for l in L:
        dic[l] += 1
    lb = 0
    ub = N // 3 + 1
    while ub - lb > 1:
        mid = (ub + lb) // 2
        if check(mid):
            lb = mid
        else:
            ub = mid
    print(lb)
            
            
            
        