結果
問題 | No.120 傾向と対策:門松列(その1) |
ユーザー | 👑 rin204 |
提出日時 | 2022-01-20 10:04:10 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 180 ms / 5,000 ms |
コード長 | 433 bytes |
コンパイル時間 | 370 ms |
コンパイル使用メモリ | 86,920 KB |
実行使用メモリ | 78,860 KB |
最終ジャッジ日時 | 2023-08-15 08:35:32 |
合計ジャッジ時間 | 1,912 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 180 ms
78,860 KB |
testcase_01 | AC | 172 ms
78,860 KB |
testcase_02 | AC | 164 ms
78,148 KB |
testcase_03 | AC | 161 ms
77,708 KB |
ソースコード
def solve(): n = int(input()) L = list(map(int, input().split())) cnt = {} for l in L: cnt[l] = cnt.get(l, 0) + 1 ans = 0 V = list(cnt.values()) l = 0 r = n // 3 + 1 while r - l > 1: mid = (l + r) // 2 c = sum(min(v, mid) for v in V) if c >= 3 * mid: l = mid else: r = mid print(l) for _ in range(int(input())): solve()