結果

問題 No.120 傾向と対策:門松列(その1)
ユーザー vwxyzvwxyz
提出日時 2022-10-18 10:47:16
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 381 ms / 5,000 ms
コード長 519 bytes
コンパイル時間 249 ms
コンパイル使用メモリ 10,780 KB
実行使用メモリ 8,616 KB
最終ジャッジ日時 2023-09-11 05:30:37
合計ジャッジ時間 2,452 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 225 ms
8,616 KB
testcase_01 AC 381 ms
8,612 KB
testcase_02 AC 200 ms
8,600 KB
testcase_03 AC 377 ms
8,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from collections import Counter
readline=sys.stdin.readline

def Bisect_Int(ok,ng,is_ok):
    while abs(ok-ng)>1:
        mid=(ok+ng)//2
        if is_ok(mid):
            ok=mid
        else:
            ng=mid
    return ok
T=int(readline())
for t in range(T):
    N=int(readline())
    L=list(map(int,readline().split()))
    C=Counter(L)
    def is_ok(ans):
        cnt=0
        for l,c in C.items():
            cnt+=min(c,ans)
        return ans*3<=cnt
    ans=Bisect_Int(0,1<<30,is_ok)
    print(ans)
0