結果

問題 No.198 キャンディー・ボックス2
ユーザー nebukuro09nebukuro09
提出日時 2016-10-25 16:25:27
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 366 bytes
コンパイル時間 162 ms
コンパイル使用メモリ 6,600 KB
実行使用メモリ 6,240 KB
最終ジャッジ日時 2023-08-15 19:12:26
合計ジャッジ時間 1,599 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

B = input()
N = input()
C = [int(raw_input()) for _ in xrange(N)]
avg = sum(C)/N+1

amari = sum(c-avg for c in C if c > avg)
tarinai = sum(avg-c for c in C if c < avg)
ans1 = amari+tarinai if amari+B >= tarinai else float('inf')
avg -= 1
amari = sum(c-avg for c in C if c > avg)
tarinai = sum(avg-c for c in C if c < avg)
ans2 = amari+tarinai

print min(ans1, ans2)
0