結果
| 問題 | No.120 傾向と対策:門松列(その1) | 
| コンテスト | |
| ユーザー |  yaoshimax | 
| 提出日時 | 2015-03-29 01:57:16 | 
| 言語 | Python2 (2.7.18) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 259 ms / 5,000 ms | 
| コード長 | 516 bytes | 
| コンパイル時間 | 97 ms | 
| コンパイル使用メモリ | 7,040 KB | 
| 実行使用メモリ | 6,940 KB | 
| 最終ジャッジ日時 | 2024-07-03 22:32:00 | 
| 合計ジャッジ時間 | 2,306 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 4 | 
ソースコード
from heapq import heappop,heappush
import collections
T=int(raw_input())
for ti in range(T):
    N=int(raw_input())
    L=map(int,raw_input().split())
    LDict=collections.Counter(L)
    hp=[]
    for v,n in LDict.items():
        heappush(hp,-n)
    ans=0
    while len(hp)>=3:
        a=heappop(hp)
        b=heappop(hp)
        c=heappop(hp)
        ans+=1
        if a+1<0:
            heappush(hp,a+1)
        if b+1<0:
            heappush(hp,b+1)
        if c+1<0:
            heappush(hp,c+1)
    print ans
            
            
            
        