結果

問題 No.158 奇妙なお使い
ユーザー yuki2006yuki2006
提出日時 2015-02-26 22:28:54
言語 PyPy2
(7.3.13)
結果
AC  
実行時間 382 ms / 5,000 ms
コード長 1,694 bytes
コンパイル時間 1,577 ms
コンパイル使用メモリ 77,724 KB
実行使用メモリ 177,012 KB
最終ジャッジ日時 2023-09-11 07:50:47
合計ジャッジ時間 12,236 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 279 ms
175,708 KB
testcase_01 AC 288 ms
176,140 KB
testcase_02 AC 278 ms
175,584 KB
testcase_03 AC 280 ms
175,388 KB
testcase_04 AC 382 ms
177,012 KB
testcase_05 AC 277 ms
175,568 KB
testcase_06 AC 277 ms
175,384 KB
testcase_07 AC 279 ms
175,704 KB
testcase_08 AC 278 ms
175,388 KB
testcase_09 AC 280 ms
175,828 KB
testcase_10 AC 283 ms
176,192 KB
testcase_11 AC 280 ms
175,732 KB
testcase_12 AC 281 ms
175,512 KB
testcase_13 AC 282 ms
175,588 KB
testcase_14 AC 286 ms
176,044 KB
testcase_15 AC 293 ms
176,108 KB
testcase_16 AC 289 ms
175,928 KB
testcase_17 AC 302 ms
176,640 KB
testcase_18 AC 295 ms
176,208 KB
testcase_19 AC 276 ms
175,600 KB
testcase_20 AC 297 ms
176,296 KB
testcase_21 AC 280 ms
175,868 KB
testcase_22 AC 286 ms
176,116 KB
testcase_23 AC 286 ms
175,876 KB
testcase_24 AC 288 ms
175,620 KB
testcase_25 AC 280 ms
175,568 KB
testcase_26 AC 283 ms
175,912 KB
testcase_27 AC 284 ms
175,388 KB
testcase_28 AC 281 ms
175,880 KB
testcase_29 AC 287 ms
176,016 KB
testcase_30 AC 290 ms
176,204 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding: utf-8 -*-

def solve(A, Db, B, Dc, C):
    LA = 10001
    LB = 11
    LC = 101
    mx = 0
    dp = [[[-1 for _ in xrange(LC)] for _ in xrange(LB)] for _ in xrange(LA)]
    dp[0][A[0]][A[1]] = A[2]
    for i in xrange(1, LA):
        for j in xrange(0, LB):
            for k in xrange(0, LC):
                if dp[i - 1][j][k] == -1:
                    continue
                d = Db
                use1000 = min(j, d / 1000)
                d -= use1000 * 1000

                use100 = min(k, d / 100)
                d -= use100 * 100
                if d <= dp[i - 1][j][k]:
                    # お使いが可能ならお使いをする
                    dp[i][j - use1000 + B[0]][k - use100 + B[1]] = max(dp[i][j - use1000 + B[0]][k - use100 + B[1]],
                                                                       dp[i - 1][j][k] - d + B[2])

                    mx = max(mx, i)

                d = Dc
                use1000 = min(j, d / 1000)
                d -= use1000 * 1000

                use100 = min(k, d / 100)
                d -= use100 * 100
                if d <= dp[i - 1][j][k]:
                    # お使いが可能ならお使いをする
                    dp[i][j - use1000 + C[0]][k - use100 + C[1]] = max(dp[i][j - use1000 + C[0]][k - use100 + C[1]],
                                                                       dp[i - 1][j][k] - d + C[2])

                    mx = max(mx, i)
    return mx


if __name__ == '__main__':
    A = map(int, raw_input().split())
    Db = int(raw_input())
    B = map(int, raw_input().split())
    Dc = int(raw_input())
    C = map(int, raw_input().split())
    print solve(A, Db, B, Dc, C)
0