結果

問題 No.198 キャンディー・ボックス2
ユーザー 👑 Kazun
提出日時 2020-06-12 04:06:09
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 340 bytes
コンパイル時間 301 ms
コンパイル使用メモリ 82,504 KB
実行使用メモリ 54,476 KB
最終ジャッジ日時 2024-06-24 03:37:42
合計ジャッジ時間 2,708 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 7 WA * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

B=int(input())
N=int(input())
C=[]
for i in range(N):
    C.append(int(input()))

C.sort()
S=sum(C)
T=0

Z=0
K=(S//N)*N
if  (S//N != (S+B)//N) and S-K>=K+N-S:
    U=K+N-S

    i=0
    while U>0:
        D=min(U,C[i]-S//N+1)
        Z+=D
        C[i]+=D
        U-=D
        i+=1

S=sum(C)
for i in range(N):
    Z+=abs(C[i]-S//N)

print(Z)
0