結果
問題 | No.120 傾向と対策:門松列(その1) |
ユーザー |
|
提出日時 | 2016-10-30 17:37:26 |
言語 | PyPy2 (7.3.15) |
結果 |
AC
|
実行時間 | 366 ms / 5,000 ms |
コード長 | 487 bytes |
コンパイル時間 | 273 ms |
コンパイル使用メモリ | 76,732 KB |
実行使用メモリ | 83,424 KB |
最終ジャッジ日時 | 2024-11-24 23:47:15 |
合計ジャッジ時間 | 2,827 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 4 |
ソースコード
from collections import Counter import heapq def solve(): N = int(raw_input()) L = map(int, raw_input().split()) L = [-v for v in Counter(L).values()] heapq.heapify(L) ans = 0 while len(L) >= 3: a, b, c = heapq.heappop(L), heapq.heappop(L), heapq.heappop(L) ans += 1 if a < -1: heapq.heappush(L, a+1) if b < -1: heapq.heappush(L, b+1) if c < -1: heapq.heappush(L, c+1) print ans for _ in xrange(input()): solve()