結果

問題 No.3068 Speedrun (Hard)
ユーザー AngrySadEight
提出日時 2025-02-19 00:29:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 599 ms / 2,000 ms
コード長 973 bytes
コンパイル時間 347 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 62,208 KB
最終ジャッジ日時 2025-02-19 00:29:57
合計ジャッジ時間 7,136 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

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

for a in range(A + 1):
    for b in range(B + 1):
        rem_n = N - a - b
        rem_t = T - a * P - b * Q

        if R == S:
            if rem_n * R != rem_t:
                continue
            else:
                if C + D < rem_n:
                    continue
                else:
                    nc = min(C, rem_n)
                    print(a, b, nc, rem_n - nc)
                    exit()
        elif R < S:
            if (rem_n * S - rem_t) % (S - R) != 0:
                continue
            c = (rem_n * S - rem_t) // (S - R)
            d = rem_n - c
            if c >= 0 and c <= C and d >= 0 and d <= D:
                print(a, b, c, d)
                exit()
        else:
            c = (rem_t - rem_n * S) // (R - S)
            d = rem_n - c
            if c >= 0 and c <= C and d >= 0 and d <= D:
                print(a, b, c, d)
                exit()
0