int check(vector<int> &cost, int ind, int total, vector<vector<int>> &dp)
{
if (cost.size() == ind)
return 0;
if (dp[total][ind] != 0)
return dp[total][ind];
if (cost[ind] <= total)
{
int price = cost[ind] - (9 * cost[ind]) / 10;
return dp[total][ind] = max(1 + check(cost, ind + 1, total - price, dp), check(cost, ind + 1, total, dp));
}
return check(cost, ind + 1, total, dp);
}
int max_courses(int n, int total, vector<int> &cost)
{
// Create a 2D vector for memoization
vector<vector<int>> dp(total + 1, vector<int>(cost.size() + 1, 0));
return check(cost, 0, total, dp);
}