結果

問題 No.3681 心の沸騰石
コンテスト
ユーザー Kude
提出日時 2026-09-05 13:18:46
言語 PyPy3
(7.3.23)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 62 ms / 2,000 ms
+ 956µs
コード長 508 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 229 ms
コンパイル使用メモリ 95,828 KB
実行使用メモリ 78,996 KB
最終ジャッジ日時 2026-09-05 13:18:53
合計ジャッジ時間 2,687 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

r, p, q = map(int, input().split())
a, b, c, d = map(int, input().split())
L = 0
R = 1
def check(x):
    rem = d
    todo = 0
    if a < x: todo += x - a
    else: rem += a - x
    if b < x: todo += x - b
    else: rem += b - x
    if c < x: todo += x - c
    else: rem += c - x
    if todo > rem: return False
    cost = todo * q + x * p
    return cost <= r

while check(R):
    L = R
    R *= 2

while R - L > 1:
    mid = (L + R) // 2
    if check(mid):
        L = mid
    else:
        R = mid
print(L)
0