// 嘘貪欲 #include #define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i) #define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i) using namespace std; using ll = long long; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, m; cin >> n >> m; using T = tuple; vector v(n + 1); reps(i, n) { int a, b, c; cin >> a >> b >> c; v[i] = {a, b, c}; } vector> sum = vector>(n + 1, vector(m + 1)); vector> last = vector>(n + 1, vector(m + 1)); reps(i, n) { auto [a, b, c] = v[i]; ll prv = 0; reps(j, m) { if (j >= a) { ll x = j / a * b; sum[i][j] = sum[i][j % a + x] + c * x; if (sum[i][j] > prv) { last[i][j] = j; } else { last[i][j] = last[i][j - 1]; } } } } vector dp(m + 1); reps(i, m) { ll ans = 0; reps(j, n) { int a = i - last[j][i]; ans = max(ans, sum[j][i] + dp[a]); } dp[i] = ans; cout << ans << "\n"; } return 0; }