結果
問題 |
No.198 キャンディー・ボックス2
|
ユーザー |
![]() |
提出日時 | 2025-09-10 17:59:54 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 529 bytes |
コンパイル時間 | 1,126 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 52,224 KB |
最終ジャッジ日時 | 2025-09-10 17:59:58 |
合計ジャッジ時間 | 3,221 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 22 WA * 4 |
ソースコード
B = int(input()) N = int(input()) C = [int(input()) for _ in range(N)] C.sort() SUM = sum(C) rui = [0] for c in C: rui.append(rui[-1] + c) ansl = [] for i in range(N): target = C[i] temochi = B # 左には i 個いる temochi -= target * i - rui[i] # 右には N - 1 - i 個いる temochi += (SUM - rui[i + 1]) - target * (N - i - 1) if temochi >= 0: ans = 0 for i in range(N): c = C[i] ans += abs(c - target) ansl.append(ans) print(min(ansl))