#include #include #include using namespace std; using ll = long long; const ll INF = LLONG_MAX / 4; void chmax(ll& a, ll b) { if(a < b) a = b; } int main() { int N, X, Y; cin >> N >> X >> Y; vector dp(X + 1, vector(Y + 1, 0LL)); dp[0][0] = 0; while(N--) { int A, B, C; cin >> A >> B >> C; for(int x = X; x >= A; x--) for(int y = Y; y >= B; y--) { chmax(dp[x][y], dp[x - A][y - B] + C); } } cout << dp[X][Y] << endl; }