結果
| 問題 |
No.120 傾向と対策:門松列(その1)
|
| コンテスト | |
| ユーザー |
mkawa2
|
| 提出日時 | 2019-12-24 16:48:37 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 102 ms / 5,000 ms |
| コード長 | 1,018 bytes |
| コンパイル時間 | 117 ms |
| コンパイル使用メモリ | 12,928 KB |
| 実行使用メモリ | 11,136 KB |
| 最終ジャッジ日時 | 2024-09-22 04:59:42 |
| 合計ジャッジ時間 | 1,350 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 |
ソースコード
from collections import *
from heapq import *
import sys
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MF(): return map(float, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LF(): return list(map(float, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def main():
t=II()
for _ in range(t):
n=II()
ll=LI()
ll=Counter(ll)
ll=[-x for x in ll.values()]
heapify(ll)
ans=0
while len(ll)>2:
l1=-heappop(ll)
l2=-heappop(ll)
l3=-heappop(ll)
#print(l1,l2,l3,ll)
l1-=1
l2-=1
l3-=1
ans+=1
if l1:heappush(ll,-l1)
if l2:heappush(ll,-l2)
if l3:heappush(ll,-l3)
print(ans)
main()
mkawa2