結果
問題 |
No.120 傾向と対策:門松列(その1)
|
ユーザー |
![]() |
提出日時 | 2022-06-22 19:11:45 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 137 ms / 5,000 ms |
コード長 | 588 bytes |
コンパイル時間 | 337 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 11,008 KB |
最終ジャッジ日時 | 2024-11-06 05:16:56 |
合計ジャッジ時間 | 1,527 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 4 |
ソースコード
from collections import defaultdict from heapq import heappop,heappush def solve(): N = int(input()) L = list(map(int,input().split())) dic = defaultdict(int) for i in range(N): dic[L[i]] += 1 hq = [] for v in dic.values(): heappush(hq, -v) ans = 0 while len(hq) >= 3: ans += 1 v = [] for _ in range(3): v.append(heappop(hq)) for i in range(3): if v[i] + 1 == 0: continue heappush(hq, v[i]+1) print(ans) T = int(input()) for _ in range(T): solve()