結果
問題 |
No.2317 Expression Menu
|
ユーザー |
![]() |
提出日時 | 2023-06-23 18:02:16 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 50 ms / 2,000 ms |
コード長 | 996 bytes |
コンパイル時間 | 321 ms |
コンパイル使用メモリ | 42,880 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-30 21:50:49 |
合計ジャッジ時間 | 2,477 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 37 |
ソースコード
/* -*- coding: utf-8 -*- * * 2317.cc: No.2317 Expression Menu - yukicoder */ #include<cstdio> #include<algorithm> using namespace std; /* constant */ const int MAX_N = 300; const int MAX_X = 300; const int MAX_Y = 300; /* typedef */ typedef long long ll; /* global variables */ int as[MAX_N], bs[MAX_N], cs[MAX_N]; ll dp[MAX_X + 1][MAX_Y + 1]; /* subroutines */ inline void setmax(ll &a, ll b) { if (a < b) a = b; } /* main */ int main() { int n, x, y; scanf("%d%d%d", &n, &x, &y); for (int i = 0; i < n; i++) scanf("%d%d%d", as + i, bs + i, cs + i); for (int i = 0; i <= x; i++) fill(dp[i], dp[i] + y + 1, -1); dp[0][0] = 0; for (int i = 0; i < n; i++) for (int j = x - as[i]; j >= 0; j--) for (int k = y - bs[i]; k >= 0; k--) if (dp[j][k] >= 0) setmax(dp[j + as[i]][k + bs[i]], dp[j][k] + cs[i]); ll maxd = 0; for (int j = 0; j <= x; j++) for (int k = 0; k <= y; k++) setmax(maxd, dp[j][k]); printf("%lld\n", maxd); return 0; }