結果

問題 No.120 傾向と対策:門松列(その1)
ユーザー ktshunktshun
提出日時 2015-06-11 23:14:19
言語 Python2
(2.7.18)
結果
AC  
実行時間 138 ms / 5,000 ms
コード長 454 bytes
コンパイル時間 79 ms
コンパイル使用メモリ 6,704 KB
実行使用メモリ 6,776 KB
最終ジャッジ日時 2023-09-20 20:59:14
合計ジャッジ時間 1,148 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
6,520 KB
testcase_01 AC 138 ms
6,500 KB
testcase_02 AC 86 ms
6,776 KB
testcase_03 AC 136 ms
6,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- 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]
	no2 = cnt.most_common(2)[1][1]
	if no1 <= n /3.0:
		print n / 3
		return
	else:
		if no2 > (n - no1)/2:
			print n - no1 - no2
			return
		else:
			print (n-no1) / 2
			return

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