結果

問題 No.2317 Expression Menu
ユーザー とろちゃとろちゃ
提出日時 2023-05-26 22:37:51
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 2,337 bytes
コンパイル時間 392 ms
コンパイル使用メモリ 87,332 KB
実行使用メモリ 116,864 KB
最終ジャッジ日時 2023-08-26 12:45:46
合計ジャッジ時間 8,457 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
76,244 KB
testcase_01 AC 75 ms
76,012 KB
testcase_02 AC 90 ms
77,208 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 180 ms
112,888 KB
testcase_08 WA -
testcase_09 AC 173 ms
112,284 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 177 ms
112,528 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 179 ms
112,628 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 179 ms
112,612 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 70 ms
75,256 KB
testcase_34 AC 69 ms
75,232 KB
testcase_35 AC 72 ms
75,332 KB
testcase_36 AC 71 ms
75,128 KB
testcase_37 AC 69 ms
75,292 KB
testcase_38 AC 169 ms
116,864 KB
testcase_39 AC 169 ms
113,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# import pypyjit;pypyjit.set_param("max_unroll_recursion=-1")
# from bisect import *
# from collections import *
# from heapq import *
# from itertools import *
# from math import *
# from datetime import *
# from decimal import*
# from string import ascii_lowercase,ascii_uppercase
# import numpy as np
import sys
import os

# sys.setrecursionlimit(10**6)
INF = 10**18
MOD = 998244353
# MOD = 10**9 + 7
File = open("input.txt", "r") if os.path.exists("input.txt") else sys.stdin


def input():
    return File.readline()[:-1]


# ///////////////////////////////////////////////////////////////////////////


N, X, Y = map(int, input().split())
menu = [list(map(int, input().split())) for _ in range(N)] + [[0, 0, 0]]
dp = [[[0, 0] for _ in range(700)] for _ in range(N + 1)]
flag = [0] * 700
flag[0] = 1

for i in range(N + 1):
    for j in range(500):
        if flag[j]:
            if j + menu[i][0] <= X and dp[i - 1][j][0] + menu[i][1] <= Y:
                dp[i][j + menu[i][0]] = (
                    dp[i][j + menu[i][0]]
                    if dp[i][j + menu[i][0]][1] > dp[i - 1][j][1] + menu[i][2]
                    else [
                        dp[i - 1][j][0] + menu[i][1],
                        dp[i - 1][j][1] + menu[i][2],
                    ]
                )
                flag[j + menu[i][0]] = 1
            dp[i][j] = dp[i][j] if dp[i][j][1] > dp[i - 1][j][1] else dp[i - 1][j]

ans = 0
for i, j in enumerate(dp[-1]):
    if i <= X and j[0] <= Y:
        if ans < j[1]:
            ans = j[1]

dp = [[[0, 0] for _ in range(700)] for _ in range(N + 1)]
flag = [0] * 700
flag[0] = 1

for i in range(N + 1):
    for j in range(500):
        if flag[j]:
            if j + menu[i][1] <= Y and dp[i - 1][j][0] + menu[i][0] <= X:
                dp[i][j + menu[i][1]] = (
                    dp[i][j + menu[i][1]]
                    if dp[i][j + menu[i][1]][1] > dp[i - 1][j][1] + menu[i][2]
                    else [
                        dp[i - 1][j][0] + menu[i][0],
                        dp[i - 1][j][1] + menu[i][2],
                    ]
                )
                flag[j + menu[i][1]] = 1
            dp[i][j] = dp[i][j] if dp[i][j][1] > dp[i - 1][j][1] else dp[i - 1][j]

for i, j in enumerate(dp[-1]):
    if i <= Y and j[0] <= X:
        if ans < j[1]:
            ans = j[1]

print(ans)
0