結果

問題 No.198 キャンディー・ボックス2
ユーザー tabataba
提出日時 2016-04-16 21:17:43
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 343 bytes
コンパイル時間 211 ms
コンパイル使用メモリ 7,040 KB
実行使用メモリ 6,528 KB
最終ジャッジ日時 2024-04-15 02:12:55
合計ジャッジ時間 1,543 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 10 ms
6,400 KB
testcase_10 AC 10 ms
6,400 KB
testcase_11 AC 10 ms
6,528 KB
testcase_12 AC 10 ms
6,400 KB
testcase_13 WA -
testcase_14 AC 10 ms
6,528 KB
testcase_15 AC 10 ms
6,528 KB
testcase_16 AC 10 ms
6,400 KB
testcase_17 AC 11 ms
6,400 KB
testcase_18 WA -
testcase_19 AC 10 ms
6,528 KB
testcase_20 AC 10 ms
6,528 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

b=input()
n=input()
c=sorted([input()for i in[0]*n])
a=0
while len(set(c))>2:
	c=sorted(c)
	a+=c[-1]-c[-2]
	b+=c[-1]-c[-2]
	c[-1]-=c[-2]
	if c[1]-c[0]<=b:
		a+=c[1]-c[0]
		b-=c[1]-c[0]
		c[0]+=c[1]-c[0]
#print c
#print b,a
if len(set(c))==2:
	l=c.count(min(c))
	h=c.count(max(c))
	if l<=b and l<h:
		print a+l
	else:
		print a+h
else:
	print a
0