結果
| 問題 | 
                            No.198 キャンディー・ボックス2
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2022-01-20 08:26:52 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 47 ms / 1,000 ms | 
| コード長 | 206 bytes | 
| コンパイル時間 | 261 ms | 
| コンパイル使用メモリ | 82,432 KB | 
| 実行使用メモリ | 52,096 KB | 
| 最終ジャッジ日時 | 2024-11-23 14:21:53 | 
| 合計ジャッジ時間 | 2,405 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 26 | 
ソースコード
b = int(input())
n = int(input())
C = [int(input()) for _ in range(n)]
C.sort()
tot = sum(C) + b
max_ = tot // n
med = C[(n - 1) // 2]
if med > max_:
    med = max_
    
print(sum(abs(med - c) for c in C))