結果

問題 No.120 傾向と対策:門松列(その1)
ユーザー HachimoriHachimori
提出日時 2015-01-08 23:51:13
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 828 bytes
コンパイル時間 739 ms
コンパイル使用メモリ 6,744 KB
実行使用メモリ 6,336 KB
最終ジャッジ日時 2023-09-03 22:43:03
合計ジャッジ時間 1,624 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python


def read():
    return input(), map(int, raw_input().split())


def work((N, vList)):
    vList.sort()
    
    cntList = []

    idx = 0
    while idx < N:
        cnt = 1
        while idx + 1 < N and vList[idx] == vList[idx + 1]:
            idx += 1
            cnt += 1
        cntList.append(cnt)
        idx += 1
    
    ans = 0
    while len(cntList) >= 3:
        if cntList[0] == 0:
            del cntList[0]
            continue
        
        if cntList[1] == 0:
            del cntList[1]
            continue
        
        if cntList[2] == 0:
            del cntList[2]
            continue
        
        ans += 1
        cntList[0] -= 1
        cntList[1] -= 1
        cntList[2] -= 1

    print ans


if __name__ == "__main__":
    for i in range(input()):
        work(read())
0