結果

問題 No.158 奇妙なお使い
ユーザー maspymaspy
提出日時 2020-03-18 12:19:31
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 827 bytes
コンパイル時間 260 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 11,904 KB
最終ジャッジ日時 2024-12-14 01:40:26
合計ジャッジ時間 2,680 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 22 RE * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3.8
# %%
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from functools import lru_cache
sys.setrecursionlimit(10**6)
# %%
A = tuple(map(int, readline().split()))
DB = int(readline())
B = tuple(map(int, readline().split()))
DC = int(readline())
C = tuple(map(int, readline().split()))


# %%
@lru_cache(None)
def f(X, Y, Z):
    ret = 0
    for cost, gain in ((DB, B), (DC, C)):
        x = cost // 1000
        if X < x:
            x = X
        cost -= 1000 * x
        y = cost // 100
        if Y < y:
            y = Y
        cost -= 100 * y
        if cost > Z:
            continue
        n = 1 + f(X - x + gain[0], Y - y + gain[1], Z - cost + gain[2])
        if ret < n:
            ret = n
    return ret


# %%
print(f(*A))
0