結果

問題 No.2317 Expression Menu
コンテスト
ユーザー norioc
提出日時 2026-10-18 03:06:37
言語 PyPy3
(8.0.0 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 259 ms / 2,000 ms
+ 189µs
コード長 519 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 84 ms
コンパイル使用メモリ 64,768 KB
実行使用メモリ 60,032 KB
最終ジャッジ日時 2026-10-18 03:06:48
合計ジャッジ時間 9,685 ms
ジャッジサーバーID
(参考情報)
judge5_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 37
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

N, X, Y = map(int, input().split())

xs = []
for _ in range(N):
    A, B, C = map(int, input().split())
    xs.append((A, B, C))

dp = [[-1] * 301 for _ in range(301)]
dp[0][0] = 0
ans = 0
for a, b, c in xs:
    for i in reversed(range(X+1)):
        for j in reversed(range(Y+1)):
            if dp[i][j] == -1: continue

            ni = i + a
            nj = j + b
            if ni <= X and nj <= Y:
                dp[ni][nj] = max(dp[ni][nj], dp[i][j] + c)
                ans = max(ans, dp[ni][nj])

print(ans)
0