結果
| 問題 | 
                            No.198 キャンディー・ボックス2
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2019-03-11 20:50:14 | 
| 言語 | Python3  (3.13.1 + numpy 2.2.1 + scipy 1.14.1)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 589 bytes | 
| コンパイル時間 | 214 ms | 
| コンパイル使用メモリ | 12,544 KB | 
| 実行使用メモリ | 10,880 KB | 
| 最終ジャッジ日時 | 2024-06-23 15:40:32 | 
| 合計ジャッジ時間 | 2,021 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 WA * 1 | 
| other | AC * 13 WA * 13 | 
ソースコード
B = int(input())
N = int(input())
C = [0]*N
sum = 0
cnt = 0
for i in range(N):
    C[i] = int(input())
    sum += C[i]
ave = int((sum+B)/N)
C.sort()
C.reverse()
'''
print(C)
for i in range(N):
    j = 0
    if C[i]>ave:
        for j in range(C[i]-ave):
            C[i] -= 1
            cnt += 1
            B += 1
    elif C[i]<ave and B>0:
        for j in range(ave-C[i]):
            C[i] += 1
            cnt += 1
            B -= 1
print(cnt)
#print(C)
'''
for i in range(N):
    if C[i]>ave:
        cnt += C[i]-ave
    elif C[i]<ave:
        cnt += ave-C[i]        
print(cnt)