結果

問題 No.198 キャンディー・ボックス2
ユーザー 👑 KazunKazun
提出日時 2020-06-12 04:06:09
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 340 bytes
コンパイル時間 289 ms
コンパイル使用メモリ 86,900 KB
実行使用メモリ 71,328 KB
最終ジャッジ日時 2023-09-06 08:54:28
合計ジャッジ時間 3,538 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 70 ms
71,200 KB
testcase_10 AC 68 ms
71,224 KB
testcase_11 AC 70 ms
70,864 KB
testcase_12 AC 71 ms
70,992 KB
testcase_13 WA -
testcase_14 AC 69 ms
71,328 KB
testcase_15 AC 70 ms
71,128 KB
testcase_16 AC 69 ms
71,224 KB
testcase_17 AC 70 ms
71,224 KB
testcase_18 WA -
testcase_19 AC 70 ms
71,328 KB
testcase_20 AC 69 ms
70,992 KB
testcase_21 AC 69 ms
71,040 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