結果
問題 | No.120 傾向と対策:門松列(その1) |
ユーザー | lllllll88938494 |
提出日時 | 2022-03-16 06:58:16 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 125 ms / 5,000 ms |
コード長 | 463 bytes |
コンパイル時間 | 115 ms |
コンパイル使用メモリ | 11,844 KB |
実行使用メモリ | 10,260 KB |
最終ジャッジ日時 | 2023-10-24 11:09:21 |
合計ジャッジ時間 | 1,594 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 120 ms
10,236 KB |
testcase_01 | AC | 125 ms
10,260 KB |
testcase_02 | AC | 81 ms
10,252 KB |
testcase_03 | AC | 123 ms
10,252 KB |
ソースコード
from collections import Counter from heapq import heapify as hpi , heappop as hpop , heappush as hpush t=int(input()) for i in range(t): n=int(input()) a=list(map(int,input().split())) c=[-i for i in Counter(a).values()] hpi(c) cnt=0 while len(c) >= 3: x=hpop(c)+1 y=hpop(c)+1 z=hpop(c)+1 for i in [x,y,z]: if i != 0: hpush(c,i) cnt+=1 print(cnt)