結果
| 問題 |
No.158 奇妙なお使い
|
| コンテスト | |
| ユーザー |
tnodino
|
| 提出日時 | 2022-07-09 21:07:05 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 221 ms / 5,000 ms |
| コード長 | 1,247 bytes |
| コンパイル時間 | 371 ms |
| コンパイル使用メモリ | 81,972 KB |
| 実行使用メモリ | 77,132 KB |
| 最終ジャッジ日時 | 2024-12-31 14:56:44 |
| 合計ジャッジ時間 | 5,911 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 27 |
ソースコード
def check(x1000, x100, x1, d, d1000, d100, d1):
m = d // 1000
if m <= x1000:
d %= 1000
x1000 -= m
else:
d -= x1000 * 1000
x1000 = 0
m = d // 100
if m <= x100:
d %= 100
x100 -= m
else:
d -= x100 * 100
x100 = 0
if d <= x1:
x1 -= d
x1000 += d1000
x100 += d100
x1 += d1
return True, x1000, x100, x1
return False, -1, -1, -1
A1000,A100,A1 = map(int,input().split())
Db = int(input())
B1000,B100,B1 = map(int,input().split())
Dc = int(input())
C1000,C100,C1 = map(int,input().split())
DP = [[-1] * 101 for _ in range(11)]
DP[A1000][A100] = A1
ans = 0
for cnt in range(1,10001):
DP2 = [[-1] * 101 for _ in range(11)]
for i in range(11):
for j in range(101):
if DP[i][j] == -1:
continue
flg,x1000,x100,x1 = check(i, j, DP[i][j], Db, B1000, B100, B1)
if flg:
DP2[x1000][x100] = max(DP2[x1000][x100], x1)
ans = cnt
flg,x1000,x100,x1 = check(i, j, DP[i][j], Dc, C1000, C100, C1)
if flg:
DP2[x1000][x100] = max(DP2[x1000][x100], x1)
ans = cnt
DP = DP2
print(ans)
tnodino