結果

問題 No.3681 心の沸騰石
コンテスト
ユーザー orangekid
提出日時 2026-09-05 16:34:40
言語 PyPy3
(7.3.23)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 63 ms / 2,000 ms
+ 983µs
コード長 672 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 230 ms
コンパイル使用メモリ 95,948 KB
実行使用メモリ 78,976 KB
最終ジャッジ日時 2026-09-05 16:34:46
合計ジャッジ時間 3,017 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_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())
s = sorted([a, b, c])
L = [(0, s[0])]
cnt = 1
for i in range(1, 3):
    if s[i] > s[i - 1]:
        L.append((L[-1][0] + cnt, s[i] - s[i - 1]))
        cnt = 1
    else:
        cnt += 1
L.append((L[-1][0] + cnt, ((a + b + c + d) // 3) - s[i]))
def check(x):
    ans = p * x
    i = 0
    while x > 0:
        y = min(x, L[i][1])
        ans += L[i][0] * y * q
        x -= y
        i += 1
    if ans > R:
        return False
    return True
l = 0
r = (a + b + c + d) // 3 + 1
m = (l + r) // 2
while r - l > 1:
    if check(m):
        l = m
    else:
        r = m
    m = (l + r) // 2
print(l)
0