結果
問題 |
No.120 傾向と対策:門松列(その1)
|
ユーザー |
![]() |
提出日時 | 2019-01-14 04:17:04 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 173 ms / 5,000 ms |
コード長 | 782 bytes |
コンパイル時間 | 149 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 11,008 KB |
最終ジャッジ日時 | 2024-12-30 04:54:57 |
合計ジャッジ時間 | 1,498 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 4 |
ソースコード
import collections import heapq def solve(N, L): c = collections.Counter() for Li in L: c[Li] -= 1 if len(c) < 3: return 0 res = 0 cnt = list(c.values()) heapq.heapify(cnt) mx = [0] * 3 while True: kadomatsu = True for i in range(len(mx)): mx[i] = heapq.heappop(cnt) if mx[i] >= 0: kadomatsu = False if kadomatsu: res += 1 else: break for i in range(len(mx)): heapq.heappush(cnt, mx[i] + 1) return res T = int(input()) lis = [0] * T for tt in range(T): nt = int(input()) lt = [int(x) for x in input().split()] lis[tt] = solve(nt, lt) print(*lis, sep='\n')