結果

問題 No.120 傾向と対策:門松列(その1)
ユーザー FromBooskaFromBooska
提出日時 2023-04-08 06:31:32
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 954 bytes
コンパイル時間 188 ms
コンパイル使用メモリ 82,096 KB
実行使用メモリ 78,420 KB
最終ジャッジ日時 2024-04-14 06:23:59
合計ジャッジ時間 1,526 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

# 同じ長さでない3本を選べばいい
# 長さごとに本数を数えて、本数降順として使うか
# それで間に合うか? N<100なので間に合うかも

T = int(input())
for t in range(T):

    N = int(input())
    L = list(map(int, input().split()))
    from collections import Counter
    counted = Counter(L)

    #print(counted)
    #print(type(counted))

    counted_list = []
    for n, c in counted.items():
        counted_list.append([n, c])
    counted_list.sort(key = lambda x:-x[1])

    #print(counted_list)

    count = 0
    while True:
        subcount = 0
        for i in range(len(counted_list)):
            if counted_list[i][1] > 0:
                subcount += 1
                counted_list[i][1] -= 1
            if subcount == 3:
                count += 1
                break
        #print('count', count, 'subcount', subcount, counted_list)
        if subcount < 3:
            break
    print(count)
0