結果
| 問題 | No.120 傾向と対策:門松列(その1) |
| コンテスト | |
| ユーザー |
あかりき
|
| 提出日時 | 2021-02-13 14:40:07 |
| 言語 | PyPy3 (7.3.23 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 293 ms / 5,000 ms |
| + 65µs | |
| コード長 | 565 bytes |
| 記録 | |
| コンパイル時間 | 250 ms |
| コンパイル使用メモリ | 96,104 KB |
| 実行使用メモリ | 88,916 KB |
| 最終ジャッジ日時 | 2026-08-20 07:54:08 |
| 合計ジャッジ時間 | 2,987 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 |
ソースコード
import heapq
import collections
t=int(input())
for i in range(t):
n=int(input())
l=list(map(int,input().split()))
l=collections.Counter(l)
l=list(l.values())
if len(l)<3:
print(0)
else:
for i in range(len(l)):
l[i]*=-1
heapq.heapify(l)
ans=0
for i in range(n//3+1):
a=heapq.heappop(l)
b=heapq.heappop(l)
c=heapq.heappop(l)
if a<0 and b<0 and c<0:
a+=1;b+=1;c+=1
ans+=1
else:
break
heapq.heappush(l,a)
heapq.heappush(l,b)
heapq.heappush(l,c)
print(ans)
あかりき