結果

問題 No.120 傾向と対策:門松列(その1)
コンテスト
ユーザー matsu7874
提出日時 2016-01-01 08:43:03
言語 Python3
(3.15.0 + numpy 2.5.4 + scipy 1.18.1 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
WA  
実行時間 -
コード長 493 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 280 ms
コンパイル使用メモリ 21,592 KB
実行使用メモリ 15,788 KB
最終ジャッジ日時 2026-08-30 23:10:35
合計ジャッジ時間 2,255 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import heapq
import collections
T=int(input())
for _ in range(T):
    N = int(input())
    L = collections.Counter(list(map(int, input().split())))
    q = [100-v for k,v in L.items()]
    cnt = 0
    while len(q)>=3:
        a = heapq.heappop(q)
        b = heapq.heappop(q)
        c = heapq.heappop(q)
        cnt += 1
        if a<100:
            heapq.heappush(q,a+1)
        if b<100:
            heapq.heappush(q,b+1)
        if c<100:
            heapq.heappush(q,c+1)
    print(cnt)
0