#include using namespace std; #include using namespace atcoder; using ll = long long; int dp[303][303]; int n,x,y; vector A,B,C; void solve(){ for(int k = 0;k=0;i--){ for(int j = y;j>=0;j--){ int a = A[k]; int b = B[k]; int c = C[k]; if(i-a>=0&&j-b>=0){ dp[i][j] = max(dp[i][j],dp[i-a][j-b]+c); } } } } cout<> n >> x >> y; A = B = C = vector(n); for(int i = 0;i> A[i] >> B[i] >> C[i]; } solve(); }