結果

問題 No.158 奇妙なお使い
ユーザー rlangevinrlangevin
提出日時 2023-09-07 12:41:19
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 2,040 bytes
コンパイル時間 298 ms
コンパイル使用メモリ 86,704 KB
実行使用メモリ 82,700 KB
最終ジャッジ日時 2023-09-07 12:41:29
合計ジャッジ時間 7,800 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 134 ms
78,764 KB
testcase_01 AC 240 ms
82,700 KB
testcase_02 WA -
testcase_03 AC 99 ms
76,864 KB
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *

A = list(map(int, input().split()))
Db = int(input())
B = list(map(int, input().split()))
Dc = int(input())
C = list(map(int, input().split()))
num = [1000, 100, 1]
Sb, Sc = 0, 0
N = 0
for i in range(3):
    N += num[i] * A[i]
    Sb += num[i] * B[i]
    Sc += num[i] * C[i]

Edge1 = []
for a in range(11):
    now = num[0] * a
    if now > Db:
        break
    for b in range(101):
        now = num[0] * a + num[1] * b
        if now > Db:
            break
        c = Db - now
        if c < 0:
            break
        Edge1.append((a, b, c))
                

Edge2 = []
for a in range(11):
    now = num[0] * a
    if now > Dc:
        break
    for b in range(101):
        now = num[0] * a + num[1] * b
        if now > Dc:
            break
        c = Dc - now
        if c < 0:
            break
        Edge2.append((a, b, c))

L = [[] for i in range(N + 1)]
L[N].append(tuple(A))
inf = 10 ** 18
D = defaultdict(lambda: -inf)
D[tuple(A)] = 0
ans = 0
for i in range(N, -1, -1):
    for a1, b1, c1 in L[i]:
        for a2, b2, c2 in Edge1:
            if a1 < a2 or b1 < b2 or c1 < c2:
                continue
            temp = max(D[(a1 - a2 + B[0], b1 - b2 + B[1], c1 - c2 + B[2])], D[(a1, b1, c1)] + 1)
            ans = max(ans, temp)
            if D[(a1 - a2 + B[0], b1 - b2 + B[1], c1 - c2 + B[2])] != -inf:
                continue
            D[(a1 - a2 + B[0], b1 - b2 + B[1], c1 - c2 + B[2])] = temp
            L[i - Db + Sb].append((a1 - a2 + B[0], b1 - b2 + B[1], c1 - c2 + B[2]))

        for a2, b2, c2 in Edge2:
            if a1 < a2 or b1 < b2 or c1 < c2:
                continue
            temp = max(D[(a1 - a2 + C[0], b1 - b2 + C[1], c1 - c2 + C[2])], D[(a1, b1, c1)] + 1)
            ans = max(ans, temp)
            if D[(a1 - a2 + C[0], b1 - b2 + C[1], c1 - c2 + C[2])] != -inf:
                continue
            D[(a1 - a2 + C[0], b1 - b2 + C[1], c1 - c2 + C[2])] = temp
            L[i - Dc + Sc].append((a1 - a2 + C[0], b1 - b2 + C[1], c1 - c2 + C[2]))


print(ans)
0