結果

問題 No.3681 心の沸騰石
コンテスト
ユーザー ゆにたりー卿
提出日時 2026-06-18 01:52:38
言語 PyPy3
(7.3.23 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 58 ms / 2,000 ms
+ 758µs
コード長 625 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 233 ms
コンパイル使用メモリ 96,080 KB
実行使用メモリ 79,048 KB
最終ジャッジ日時 2026-09-05 12:30:49
合計ジャッジ時間 2,577 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

def solve():
    R, P, Q = map(int, input().split())
    CNTS = list(map(int, input().split()))
    
    def judge(x):
        required_cnt = sum(max(x - cnt, 0) for cnt in CNTS[:-1])
        extra_cnt = sum(max(cnt - x, 0) for cnt in CNTS[:-1]) + CNTS[-1]
        return (extra_cnt >= required_cnt) and (required_cnt * Q + x * P <= R)
    
    ans = binary_search(judge)
    print(ans)

def binary_search(judge, ok = 0, ng = 1 << 62):
    while abs(ok - ng) > 1:
        med = (ng + ok) // 2
        if judge(med):
            ok = med
        else:
            ng = med
    return ok

if __name__ == "__main__":
    solve()
0