#include using namespace std; using i64 = int64_t; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, x, y; cin >> n >> x >> y; i64 ans = 0; vector dp(x + 1, vector(y + 1)); for (int i = 0, a, b, c; i < n; i += 1) { cin >> a >> b >> c; for (int j = x; j >= a; j -= 1) { for (int k = y; k >= b; k -= 1) { ans = max(ans, dp[j][k] = max(dp[j][k], dp[j - a][k - b] + c)); } } } cout << ans; }