#include #include #include using namespace std; int main() { int N, M; cin >> N >> M; vector> dp(N + 1, vector(M + 1, 0)); vector> A(N + 1, vector(3)); // 入力処理 for (int i = 1; i <= N; i++) { for (int j = 0; j < 3; j++) { cin >> A[i][j]; } } // DP計算 for (int i = 1; i <= N; i++) { for (int j = 1; j <= M; j++) { dp[i][j] = dp[i - 1][j]; if (j >= A[i][0]) { int k = (j - A[i][0]) / (A[i][0] - A[i][1]); dp[i][j] = max(dp[i][j], dp[i - 1][j - A[i][0] - k * (A[i][0] - A[i][1])] + (k + 1) * A[i][1] * A[i][2]); } } } // 結果出力 for (int j = 1; j <= M; j++) { cout << dp[N][j] << endl; } return 0; }