結果
| 問題 |
No.120 傾向と対策:門松列(その1)
|
| コンテスト | |
| ユーザー |
convexineq
|
| 提出日時 | 2020-12-16 09:57:43 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 390 ms / 5,000 ms |
| コード長 | 466 bytes |
| コンパイル時間 | 437 ms |
| コンパイル使用メモリ | 82,304 KB |
| 実行使用メモリ | 80,484 KB |
| 最終ジャッジ日時 | 2024-09-20 04:32:16 |
| 合計ジャッジ時間 | 2,831 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 |
ソースコード
T = int(input())
from collections import Counter
from heapq import *
for _ in range(T):
n = int(input())
a = map(int,input().split())
d = Counter(a)
*s, = sorted(-v for k,v in d.items())
ans = 0
heapify(s)
while len(s) >= 3:
ans += 1
x = heappop(s)
y = heappop(s)
z = heappop(s)
if x <= -2: heappush(s,x+1)
if y <= -2: heappush(s,y+1)
if z <= -2: heappush(s,z+1)
print(ans)
convexineq