結果

問題 No.198 キャンディー・ボックス2
ユーザー gorugo30
提出日時 2021-03-17 20:21:11
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 285 bytes
コンパイル時間 139 ms
コンパイル使用メモリ 82,320 KB
実行使用メモリ 53,420 KB
最終ジャッジ日時 2024-11-15 14:46:43
合計ジャッジ時間 2,172 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 12 WA * 14
権限があれば一括ダウンロードができます

ソースコード

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