結果
問題 |
No.2317 Expression Menu
|
ユーザー |
![]() |
提出日時 | 2025-03-20 18:48:37 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 547 ms / 2,000 ms |
コード長 | 595 bytes |
コンパイル時間 | 142 ms |
コンパイル使用メモリ | 82,368 KB |
実行使用メモリ | 77,936 KB |
最終ジャッジ日時 | 2025-03-20 18:50:06 |
合計ジャッジ時間 | 10,923 ms |
ジャッジサーバーID (参考情報) |
judge4 / 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))