#include #include #define rep(i,n) for(int i=0;i vi; typedef vector vl; typedef vector> vvi; typedef vector> vvl; typedef long double ld; ostream& operator<<(ostream& os, const modint& a) {os << a.val(); return os;} template ostream& operator<<(ostream& os, const static_modint& a) {os << a.val(); return os;} template ostream& operator<<(ostream& os, const dynamic_modint& a) {os << a.val(); return os;} template istream& operator>>(istream& is, vector& v){int n = v.size(); assert(n > 0); rep(i, n) is >> v[i]; return is;} template ostream& operator<<(ostream& os, const pair& p){os << p.first << ' ' << p.second; return os;} template ostream& operator<<(ostream& os, const vector& v){int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "\n" : " "); return os;} template ostream& operator<<(ostream& os, const vector>& v){int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "\n" : ""); return os;} template void chmin(T& a, T b){a = min(a, b);} template void chmax(T& a, T b){a = max(a, b);} int main(){ int n, m; cin >> m >> n; vector a(m); vector b(m); vector c(m); rep(i, m) cin >> a[i] >> b[i] >> c[i]; using P = pair; vector> f(n + 1, vector

(m)); vector g(n + 1); for(int i = 1; i <= n; i++){ rep(j, m){ auto [val, rest] = f[i - 1][j]; rest++; if(rest >= a[j]){ val += b[j] * c[j]; rest = b[j]; } f[i][j] = {val, rest}; chmax(g[i], val); } for(int i2 = 0; i2 < i; i2++){ chmax(g[i], g[i2] + g[i - i2]); } cout << g[i] << "\n"; } // cout << f; return 0; }