結果
問題 | No.2317 Expression Menu |
ユーザー |
![]() |
提出日時 | 2023-05-29 00:36:12 |
言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 52 ms / 2,000 ms |
コード長 | 881 bytes |
コンパイル時間 | 2,384 ms |
コンパイル使用メモリ | 142,024 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-27 22:40:06 |
合計ジャッジ時間 | 5,058 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 37 |
ソースコード
#include <cassert> #include <cmath> #include <algorithm> #include <iostream> #include <iomanip> #include <climits> #include <map> #include <queue> #include <set> #include <cstring> #include <vector> using namespace std; typedef long long ll; int main() { int N, X, Y; cin >> N >> X >> Y; int A[N]; int B[N]; ll C[N]; for (int i = 0; i < N; ++i) { cin >> A[i] >> B[i] >> C[i]; } ll dp[X + 1][Y + 1]; memset(dp, -1, sizeof(dp)); dp[0][0] = 0; ll ans = 0; for (int i = 0; i < N; ++i) { int a = A[i]; int b = B[i]; ll c = C[i]; for (int x = X - a; x >= 0; --x) { int nx = x + a; for (int y = Y - b; y >= 0; --y) { int ny = y + b; if (dp[x][y] == -1) continue; dp[nx][ny] = max(dp[nx][ny], dp[x][y] + c); ans = max(ans, dp[nx][ny]); } } } cout << ans << endl; return 0; }