191ms beats 99.66%
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: $$O(n^2lgn)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(n^2)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    int maxStarSum(vector<int>& vals, vector<vector<int>>& edges, int k) {\n        vector<vector<int>> v(vals.size());\n        for(auto i : edges){\n            v[i[0]].push_back(vals[i[1]]);\n            v[i[1]].push_back(vals[i[0]]);\n        }\n\n        int ans = INT_MIN;\n        for(int i = 0;i < vals.size();i++){\n            int val = vals[i], s = v[i].size();\n            sort(v[i].begin(), v[i].end());\n            for(int j = s - 1;j >= max(s - k, 0);j--){\n                if(v[i][j] > 0) val += v[i][j];\n                else break;\n            }\n\n            ans = max(ans, val);\n        }\n\n        return ans;\n    }\n};\n\nauto init = []()\n{ \n    ios::sync_with_stdio(0);\n    cin.tie(0);\n    cout.tie(0);\n    return \'c\';\n}();\n```
['Array', 'Greedy', 'Graph', 'Sorting', 'C++']