結果

問題 No.158 奇妙なお使い
ユーザー chocoruskchocorusk
提出日時 2020-09-13 22:25:05
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,546 ms / 5,000 ms
コード長 931 bytes
コンパイル時間 93 ms
コンパイル使用メモリ 10,908 KB
実行使用メモリ 85,268 KB
最終ジャッジ日時 2023-09-03 23:59:31
合計ジャッジ時間 3,744 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,240 KB
testcase_01 AC 21 ms
8,564 KB
testcase_02 AC 18 ms
8,308 KB
testcase_03 AC 17 ms
8,312 KB
testcase_04 AC 1,546 ms
85,268 KB
testcase_05 AC 17 ms
8,320 KB
testcase_06 AC 16 ms
8,320 KB
testcase_07 AC 16 ms
8,228 KB
testcase_08 AC 16 ms
8,188 KB
testcase_09 AC 16 ms
8,196 KB
testcase_10 AC 18 ms
8,312 KB
testcase_11 AC 18 ms
8,384 KB
testcase_12 AC 16 ms
8,324 KB
testcase_13 AC 16 ms
8,160 KB
testcase_14 AC 19 ms
8,488 KB
testcase_15 AC 24 ms
8,548 KB
testcase_16 AC 17 ms
8,416 KB
testcase_17 AC 41 ms
9,400 KB
testcase_18 AC 231 ms
18,780 KB
testcase_19 AC 17 ms
8,392 KB
testcase_20 AC 19 ms
8,456 KB
testcase_21 AC 48 ms
9,936 KB
testcase_22 AC 49 ms
10,764 KB
testcase_23 AC 17 ms
8,180 KB
testcase_24 AC 16 ms
8,368 KB
testcase_25 AC 16 ms
8,296 KB
testcase_26 AC 17 ms
8,392 KB
testcase_27 AC 16 ms
8,216 KB
testcase_28 AC 21 ms
8,468 KB
testcase_29 AC 17 ms
8,348 KB
testcase_30 AC 33 ms
9,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
read=sys.stdin.buffer.read
readline=sys.stdin.buffer.readline
readlines=sys.stdin.buffer.readlines
sys.setrecursionlimit(10**6)
a1000, a100, a1=map(int, readline().split())
db=int(readline())
b1000, b100, b1=map(int, readline().split())
dc=int(readline())
c1000, c100, c1=map(int, readline().split())
dp={}
def solve(x1000, x100, x1):
    if (x1000, x100, x1) in dp:
        return dp[(x1000, x100, x1)]
    ans=0
    b=db
    z1000=min(b//1000, x1000)
    b-=z1000*1000
    z100=min(b//100, x100)
    b-=z100*100
    z1=min(b, x1)
    b-=z1
    if b==0:
        ans=max(ans, solve(x1000-z1000+b1000, x100-z100+b100, x1-z1+b1)+1)
    c=dc
    z1000=min(c//1000, x1000)
    c-=z1000*1000
    z100=min(c//100, x100)
    c-=z100*100
    z1=min(c, x1)
    c-=z1
    if c==0:
        ans=max(ans, solve(x1000-z1000+c1000, x100-z100+c100, x1-z1+c1)+1)
    dp[(x1000, x100, x1)]=ans
    return ans
print(solve(a1000, a100, a1))
0