結果
| 問題 |
No.120 傾向と対策:門松列(その1)
|
| コンテスト | |
| ユーザー |
しらっ亭
|
| 提出日時 | 2015-07-01 03:01:09 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 118 ms / 5,000 ms |
| コード長 | 727 bytes |
| コンパイル時間 | 107 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 10,880 KB |
| 最終ジャッジ日時 | 2024-07-07 21:36:33 |
| 合計ジャッジ時間 | 1,043 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 |
ソースコード
from collections import Counter
import heapq
def solve(N, L):
c2 = Counter(Counter(L).values())
h = [0, 0, 0]
for n in sorted(c2.keys(), reverse=True):
k = c2[n]
for i in range(k):
heapq.heappush(h, -n)
c = 0
while h:
n1 = heapq.heappop(h)
n2 = heapq.heappop(h)
n3 = heapq.heappop(h)
if n3 == 0:
break
c += 1
heapq.heappush(h, n1 + 1)
heapq.heappush(h, n2 + 1)
heapq.heappush(h, n3 + 1)
return c
def main():
T = int(input())
for t in range(T):
N = int(input())
L = list(map(int, input().split()))
print(solve(N, L))
if __name__ == '__main__':
main()
しらっ亭