結果

問題 No.3068 Speedrun (Hard)
ユーザー titia
提出日時 2025-03-23 02:22:23
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 746 bytes
コンパイル時間 498 ms
コンパイル使用メモリ 82,640 KB
実行使用メモリ 64,348 KB
最終ジャッジ日時 2025-03-23 02:22:36
合計ジャッジ時間 12,944 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 20 WA * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

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

for x in range(A+1):
    for y in range(B+1):
        # z+w=N-x-y
        # z*R+w*S=T-x*P-y*Q

        # z*R+(N-x-y-z)*S=T-x*P-y*Q
        # z*(R-S) = T-x*P-y*Q - (N-x-y)*S

        if R==S:
            if T-x*P-y*Q - (N-x-y)*S==0:
                z=min(N-x-y,C)
                w=N-x-y-z

                if 0<=z<=C and 0<=w<=D:
                    print(x,y,N-x-y,0)
                    exit()
        else:
            if (T-x*P-y*Q - (N-x-y)*S)%(R-S)==0:
                z=(T-x*P-y*Q - (N-x-y)*S)//(R-S)
                w=N-x-y-z

                if 0<=z<=C and 0<=w<=D:
                    print(x,y,z,w)
                    exit()
0