結果

問題 No.120 傾向と対策:門松列(その1)
コンテスト
ユーザー ktshun
提出日時 2015-06-11 22:43:33
言語 PyPy2
(7.3.15)
結果
WA  
実行時間 -
コード長 420 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 109 ms
コンパイル使用メモリ 77,344 KB
最終ジャッジ日時 2025-12-03 15:36:37
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

# -*- coding:utf-8 -*-
import collections

def solve():
	n = input()
	L = map(int,raw_input().split())
	cnt = collections.Counter(L)
	if len(set(L)) < 3:
		print 0
		return
	no1 = cnt.most_common(1)[0][1]
	if no1 <= n /3:
		print n / 3
	else:
		no2 = cnt.most_common(2)[1][1]
		if no2 > n - no1:
			print n - no1 - no2
		else:
			print (n-no1) / 2

if __name__ == "__main__":
	t = input()
	for i in xrange(t):
		solve()
0