結果
| 問題 |
No.2317 Expression Menu
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-03-20 21:08:48 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 555 ms / 2,000 ms |
| コード長 | 595 bytes |
| コンパイル時間 | 188 ms |
| コンパイル使用メモリ | 82,700 KB |
| 実行使用メモリ | 77,968 KB |
| 最終ジャッジ日時 | 2025-03-20 21:09:43 |
| 合計ジャッジ時間 | 10,810 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 37 |
ソースコード
n, X, Y = map(int, input().split())
items = [tuple(map(int, input().split())) for _ in range(n)]
INF = float('-inf')
dp = [[INF] * (Y + 1) for _ in range(X + 1)]
dp[0][0] = 0 # Initial state: no items selected
for a, b, c in items:
# Iterate backwards to prevent reusing the same item
for x in range(X, a - 1, -1):
for y in range(Y, b - 1, -1):
if dp[x - a][y - b] != INF and dp[x - a][y - b] + c > dp[x][y]:
dp[x][y] = dp[x - a][y - b] + c
# Find the maximum value across all dp states
max_val = max(max(row) for row in dp)
print(max(max_val, 0))
lam6er