結果
| 問題 |
No.198 キャンディー・ボックス2
|
| コンテスト | |
| ユーザー |
norioc
|
| 提出日時 | 2025-04-12 06:31:37 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 463 bytes |
| コンパイル時間 | 345 ms |
| コンパイル使用メモリ | 82,192 KB |
| 実行使用メモリ | 54,244 KB |
| 最終ジャッジ日時 | 2025-04-12 06:31:40 |
| 合計ジャッジ時間 | 2,741 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 21 WA * 5 |
ソースコード
INF = 1 << 60
B = int(input())
N = int(input())
C = [int(input()) for _ in range(N)]
C.sort(reverse=True)
def f(v: int) -> int:
t = B
res = 0
for c in C:
if c > v: # 多い
t += c - v
res += c - v
elif c < v: # 少ない
if v - c > t: return INF
t -= v - c
res += v - c
return res
res = f(C[N // 2])
#if N % 2 == 0:
# res = min(res, f(C[N // 2 - 1]))
print(res)
norioc