結果
問題 |
No.3068 Speedrun (Hard)
|
ユーザー |
|
提出日時 | 2025-03-21 22:56:55 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,597 bytes |
コンパイル時間 | 398 ms |
コンパイル使用メモリ | 12,288 KB |
実行使用メモリ | 17,436 KB |
最終ジャッジ日時 | 2025-03-21 22:57:00 |
合計ジャッジ時間 | 4,123 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge7 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 2 TLE * 1 -- * 29 |
ソースコード
A, B, C, D, N = map(int, input().split()) P, Q, R, S, T = map(int, input().split()) max_a = min(A, N) for a in range(max_a + 1): max_b = min(B, N - a) for b in range(max_b + 1): rem = N - a - b if rem < 0: continue if rem > C + D: continue time_rem = T - a * P - b * Q if time_rem < 0: continue if R != S: denominator = R - S numerator = time_rem - S * rem if denominator == 0: continue # この場合はR == Sでないと矛盾するためスキップ if numerator % denominator != 0: continue c = numerator // denominator d = rem - c if 0 <= c <= C and 0 <= d <= D: print(a, b, c, d) exit() else: # R == Sの場合、time_rem == R * rem でなければならない if time_rem != R * rem: continue # cは0<=c <=C、d=rem -c <=D → c >= rem -D c_min = max(0, rem - D) c_max = min(C, rem) if c_min > c_max: continue # 適当なcを選ぶ。例えば最大値 c = c_max d = rem - c if d >= 0 and d <= D: print(a, b, c, d) exit() else: # 最小のcを試す c = c_min d = rem - c if c >= 0 and c <= C and d >= 0 and d <= D: print(a, b, c, d) exit()