#include #include using namespace std; long long dp[303][303][303]; int main() { int N, X, Y; cin >> N >> X >> Y; for(int i = 0; i <= N; i++) for(int j = 0; j <= X; j++) for(int k = 0; k <= Y; k++) dp[i][j][k] = -1; vector a(N), b(N), c(N); for(int i = 0; i < N; i++) { cin >> a[i] >> b[i] >> c[i]; } dp[0][0][0] = 0; for(int i = 0; i < N; i++) { for(int j = 0; j <= X; j++) { for(int k = 0; k <= Y; k++) { if(dp[i][j][k] == -1) continue; dp[i+1][j][k] = max(dp[i][j][k], dp[i+1][j][k]); dp[i+1][j+a[i]][k+b[i]] = max(dp[i][j][k] + c[i], dp[i+1][j+a[i]][k+b[i]]); } } } cout << dp[N][X][Y] << endl; return 0; }