結果

問題 No.3068 Speedrun (Hard)
コンテスト
ユーザー detteiuu
提出日時 2025-05-04 03:52:52
言語 PyPy3
(8.0.1 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WJ  
(最新)
AC  
(最初)
実行時間 -
コード長 926 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
最終ジャッジ日時 2026-11-10 16:02:23
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)

ソースコード

diff #
raw source code

A, B, C, D, N = map(int, input().split())
P, Q, R, S, T = map(int, input().split())

def func(n, t):
    if C+D < n:
        return -1, -1
    if R == S:
        if R*n == t:
            c, d = 0, 0
            c = min(t//R, C)
            if R*c < t:
                d = (t-(R*c))//R
            return c, d
        else:
            return -1, -1
    else:
        top = S*n-t
        bottom = S-R
        if top%bottom == 0:
            c = top//bottom
            if 0 <= c <= C and 0 <= n-c <= D:
                return c, n-c
            else:
                return -1, -1
        else:
            return -1, -1

for a in range(A+1):
    if N < a:
        break
    if T < P*a:
        break
    for b in range(B+1):
        if N < a+b:
            break
        if T < P*a+Q*b:
            break
        n = N-a-b
        t = T-P*a-Q*b
        c, d = func(n, t)
        if c != -1:
            exit(print(a, b, c, d))
0