結果

問題 No.120 傾向と対策:門松列(その1)
ユーザー はむ吉🐹はむ吉🐹
提出日時 2016-04-04 19:20:41
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 423 ms / 5,000 ms
コード長 663 bytes
コンパイル時間 100 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-04-14 21:29:13
合計ジャッジ時間 2,536 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 308 ms
11,008 KB
testcase_01 AC 416 ms
11,008 KB
testcase_02 AC 195 ms
11,008 KB
testcase_03 AC 423 ms
11,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
import collections


def compute_maximum(bamboos):
    answer = 0
    counter = collections.Counter(bamboos)
    if len(counter) < 3:
        return answer
    while True:
        cands = counter.most_common(3)
        if cands[-1][1] <= 0:
            return answer
        used = {x: 1 for x in [cand[0] for cand in cands]}
        counter.subtract(used)
        answer += 1


def main():
    t = int(input())
    for _ in range(t):
        _ = int(input())
        bamboos = array.array("L", map(int, input().split()))
        print(compute_maximum(bamboos))


if __name__ == '__main__':
    main()
0