結果
| 問題 | No.198 キャンディー・ボックス2 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-12-07 19:43:01 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 414 bytes |
| 記録 | |
| コンパイル時間 | 222 ms |
| コンパイル使用メモリ | 12,032 KB |
| 実行使用メモリ | 26,184 KB |
| 最終ジャッジ日時 | 2025-12-07 19:43:07 |
| 合計ジャッジ時間 | 5,567 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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)