Alice’s christmas tree Time : Space : 12345678910111213#include <bits/stdc++.h>using namespace std;int largest_visible_area(int k, std::vector<std::pair<int, int>> cylinders) { vector<int> dp(k, INT_MIN); dp[0] = 0; sort(rbegin(cylinders), rend(cylinders)); for(int i = 0; i < cylinders.size(); i ++) { auto [r,m] = cylinders[i]; if(i and cylinders[i-1].first == r) continue; for(int j = k-1; j >= 1; j--) dp[j] = max(dp[j], dp[j-1] + m); dp[0] = max(dp[0], r * r + m); } return dp[k-1];};