結果
| 問題 | No.198 キャンディー・ボックス2 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-12-07 19:44:51 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 414 bytes |
| 記録 | |
| コンパイル時間 | 285 ms |
| コンパイル使用メモリ | 82,056 KB |
| 実行使用メモリ | 91,624 KB |
| 最終ジャッジ日時 | 2025-12-07 19:44:56 |
| 合計ジャッジ時間 | 5,082 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 4 |
| other | TLE * 1 -- * 26 |
ソースコード
b = int(input())
n = int(input())
C = [int(input()) for _ in range(n)]
if n == 1:
print(0)
exit()
total = sum(C) + b
ans = 10**18
for T in range(min(C), max(C) + b + 1):
add_box, remove_box = 0, 0
for c in C:
if c < T:
add_box += T - c
else:
remove_box += c - T
if add_box <= b + remove_box:
ans = min(ans, add_box + remove_box)
print(ans)