結果
問題 |
No.1808 Fullgold Alchemist
|
ユーザー |
![]() |
提出日時 | 2025-06-10 23:15:25 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 111 ms / 2,000 ms |
コード長 | 686 bytes |
コンパイル時間 | 638 ms |
コンパイル使用メモリ | 82,764 KB |
実行使用メモリ | 103,580 KB |
最終ジャッジ日時 | 2025-06-10 23:15:30 |
合計ジャッジ時間 | 5,218 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 33 |
ソースコード
def bsearch(low: int, high: int, fun, is_complement=False) -> int: def pred(x: int) -> bool: return not fun(x) if is_complement else fun(x) lo = low hi = high res = low while lo <= hi: m = (lo + hi) // 2 if pred(m): res = max(res, m) lo = m + 1 else: hi = m - 1 return res + 1 if is_complement else res # 金塊を m 個生成できるか def can(m: int) -> bool: rest = 0 for a in A: rest += a - (m * M) if rest < 0: return False return rest >= 0 N, M = map(int, input().split()) A = list(map(int, input().split())) res = bsearch(0, max(A), can) print(res)