結果

問題 No.198 キャンディー・ボックス2
ユーザー KazunKazun
提出日時 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
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 38 ms
51,876 KB
testcase_10 AC 38 ms
52,456 KB
testcase_11 AC 41 ms
52,660 KB
testcase_12 AC 37 ms
53,636 KB
testcase_13 WA -
testcase_14 AC 37 ms
53,148 KB
testcase_15 AC 37 ms
52,900 KB
testcase_16 AC 37 ms
52,748 KB
testcase_17 AC 38 ms
52,896 KB
testcase_18 WA -
testcase_19 AC 38 ms
52,012 KB
testcase_20 AC 38 ms
53,224 KB
testcase_21 AC 39 ms
53,412 KB
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=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