結果

問題 No.198 キャンディー・ボックス2
ユーザー gorugo30gorugo30
提出日時 2021-03-17 20:21:11
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 285 bytes
コンパイル時間 349 ms
コンパイル使用メモリ 86,740 KB
実行使用メモリ 71,500 KB
最終ジャッジ日時 2023-08-09 18:01:46
合計ジャッジ時間 4,139 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,140 KB
testcase_01 AC 70 ms
71,364 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 70 ms
71,264 KB
testcase_10 AC 70 ms
71,128 KB
testcase_11 AC 71 ms
71,308 KB
testcase_12 AC 70 ms
71,324 KB
testcase_13 WA -
testcase_14 AC 72 ms
71,200 KB
testcase_15 AC 72 ms
71,352 KB
testcase_16 AC 72 ms
71,324 KB
testcase_17 AC 73 ms
71,380 KB
testcase_18 AC 73 ms
71,180 KB
testcase_19 AC 71 ms
71,116 KB
testcase_20 AC 72 ms
70,968 KB
testcase_21 AC 71 ms
70,972 KB
testcase_22 AC 70 ms
71,296 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 70 ms
71,232 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

B = int(input())
N = int(input())
C = [int(input()) for i in range(N)]
canmax = (sum(C) + B) // N
M1 = min(canmax, sum(C) // N)
M2 = min(canmax, M1 + 1)

ans = 0
for i in range(N):
    ans += abs(C[i] - M1)

ans2 = 0
for i in range(N):
    ans2 += abs(C[i] - M2)

print(min(ans, ans2))
0