結果

問題 No.3068 Speedrun (Hard)
ユーザー detteiuu
提出日時 2025-05-04 03:39:06
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 933 bytes
コンパイル時間 458 ms
コンパイル使用メモリ 82,752 KB
実行使用メモリ 66,172 KB
最終ジャッジ日時 2025-05-04 03:39:18
合計ジャッジ時間 11,604 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 31 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

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 t%R == 0 and t <= R*n:
            c, d = 0, 0
            c = min(t//R, C)
            if c*R < t:
                d = t//R-C
            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