/* -*- coding: utf-8 -*- * * 2317.cc: No.2317 Expression Menu - yukicoder */ #include #include 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; }