結果

問題 No.158 奇妙なお使い
ユーザー tnodinotnodino
提出日時 2022-07-09 21:07:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 238 ms / 5,000 ms
コード長 1,247 bytes
コンパイル時間 279 ms
コンパイル使用メモリ 87,272 KB
実行使用メモリ 78,732 KB
最終ジャッジ日時 2023-08-30 05:25:19
合計ジャッジ時間 7,199 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 152 ms
77,324 KB
testcase_01 AC 160 ms
77,408 KB
testcase_02 AC 151 ms
77,184 KB
testcase_03 AC 146 ms
77,380 KB
testcase_04 AC 238 ms
78,732 KB
testcase_05 AC 143 ms
77,120 KB
testcase_06 AC 145 ms
77,236 KB
testcase_07 AC 146 ms
77,144 KB
testcase_08 AC 143 ms
77,148 KB
testcase_09 AC 149 ms
77,156 KB
testcase_10 AC 156 ms
77,264 KB
testcase_11 AC 152 ms
77,040 KB
testcase_12 AC 151 ms
77,368 KB
testcase_13 AC 150 ms
77,028 KB
testcase_14 AC 149 ms
77,016 KB
testcase_15 AC 165 ms
77,572 KB
testcase_16 AC 159 ms
77,084 KB
testcase_17 AC 178 ms
77,176 KB
testcase_18 AC 177 ms
77,448 KB
testcase_19 AC 148 ms
77,100 KB
testcase_20 AC 170 ms
77,500 KB
testcase_21 AC 151 ms
77,424 KB
testcase_22 AC 150 ms
76,924 KB
testcase_23 AC 152 ms
77,176 KB
testcase_24 AC 154 ms
76,880 KB
testcase_25 AC 144 ms
77,152 KB
testcase_26 AC 152 ms
77,060 KB
testcase_27 AC 148 ms
77,104 KB
testcase_28 AC 152 ms
77,184 KB
testcase_29 AC 148 ms
77,068 KB
testcase_30 AC 156 ms
77,168 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
0